Question

We're trying to use ImageResizer to manage our already enormous collection of stored images, and some of them, like Product Images or Header logos we want cached, and that works beautifully using the DiskCache plugin and is awesome.

But, we have other images, like id photos of children and scans of birth certificates, that we want to use ImageResizer for processing, but don't want to be cached, just in case.

I've already had to write some IPlugin's to access our rather... convoluted existing file structure, can I mark in there that the results are not cache-able? Or is there some ability on the DiskCache config line that I haven't noticed yet to whitelist (or blacklist) paths?

Thanks in advance

EDIT: Code of Pipeline Rewrite event as suggested below:

private void PipelineOnRewrite( IHttpModule sender, HttpContext context, IUrlEventArgs urlEventArgs )
{
  if( urlEventArgs.VirtualPath.Contains( VirtualFilesystemPrefix ) )
  {
    urlEventArgs.QueryString.Add("cache", "no");
  }
}
Was it helpful?

Solution

DiskCache does protect cached images via access control, using UrlAuthorization (if you have that IIS module installed, as you should).

That said, you can set &cache=no on any request to prevent disk caching. You can do this automatically, server-side, based on any criteria you want, using the Config.Current.Pipeline.Rewrite event handler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top