Imageprocessor: Uploading new images is not breaking cache with AzureBlobCache plugin

Created on 13 Jun 2017  路  16Comments  路  Source: JimBobSquarePants/ImageProcessor

Hi James,

I am having an issue where my images are not refreshing after I re-upload a new image with the same name. I found this (https://github.com/JimBobSquarePants/ImageProcessor/issues/116 ) post which discusses the same issue but I don't think they were using the AzureBlobCache plugin. From what I understand, upon uploading a new image it should refresh the cache as a time stamp is used on your end to ensure the cache is busted.

This is definitely not a browser cache issue as I have refreshed cache, used incognito all of which return me the original image. If I apply a random query string on the URL I will get the new image.

I am using the following packages:

ImageProcessor: version="2.5.3"
ImageProcessor.Web: version="4.8.3"
ImageProcessor.Web.Config: version="2.3.0.0"
ImageProcessor.Web.Plugins.AzureBlobCache: version="1.3.1

Here are my cache.config settings

<cache name="AzureBlobCache" type="ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache, ImageProcessor.Web.Plugins.AzureBlobCache" maxDays="365" trimCache="true">
<settings>
        <setting key="CachedStorageAccount" value="DefaultEndpointsProtocol=https;AccountName=my storage;AccountKey=my key" />
        <!-- Container in storage account used for cache -->
        <setting key="CachedBlobContainer" value="cache" />
        <setting key="UseCachedContainerInUrl" value="true" />
        <!-- CDN Connected to blob storage account -->
        <setting key="CachedCDNRoot" value="http://mycdnurl/" />
        <setting key="CachedCDNTimeout" value="1000" />
        <setting key="SourceStorageAccount" value="" />
        <setting key="SourceBlobContainer" value="" />
        <setting key="StreamCachedImage" value="false" />
</settings>

Any help is appreciated.

Thank you,
Chad

bug

Most helpful comment

All 16 comments

Hi Chad,

Can you bump up you versions to the current latest release and try again? I can't support prior versions.

Also, how are you updating that image? Is it also stored in blob storage or a filesystem?

Cheers

James

Ok Ill update and try again but to answer your second question: I simply upload a new image which in turn replaces the current one in blob storage. I am only using blob storage and have no file system access for imagery.

Chad

Getting the same issue as @chadcjc - I'm using the latest version (4.8.6). What did you do to fix or workaround it?

Chris can you describe your exact setup please? I don't need config details just the solution architecture.

In the end to avoid caching issues on all fronts (web browser cache and CDN cache) we switched our solution to always upload an image with a new name (we used a guid).

Let me add that I'm not totally sure our problem was related to imageprocessor or the Azure Blob Plugin as I don't think it internally invalidates CDN cache upon an image change. I could be wrong but uploading a new image with the same name never changed the CDN version of the image. This leads me to believe if you want your CDN image cache removed you will need to do that yourself.

Anyway thanks for a great product James Ill buy you a beer for your troubles :)

Thank you, @chadcjc and @JimBobSquarePants ,

Setup is pretty much exactly the same as chad's. My first thought was to use unique filenames as this appeared to be a workaround. However I think we've found the issue and once we've tested it we'll see if we can make a PR or at least point you at the bit that wants updating. Many Thanks!

@christh That would be great!

We've just hit something similar. We have a custom IImageService based on storing images in Azure blob storage which are not public. If the contents of the blob are updated (at the same URL), then the disk cached versions are not updated.

Digging into the source, I can see that you _attempt_ to make a remote request and get a LastModified from the headers, that won't work in our case as the server will return a non-200 status code (the blob items are not public). This is in the IsUpdatedAsync method - unfortunately that one is private, so will be a bit of a pain to replace.

@JimBobSquarePants - we're not using the AzureBlobCache (our image sources are stored on Azure, but the resized versions are on Disk, using DiskCache) - but broadly, yes we need that method to be something we can override.

To clarify, having that protected virtual in both DiskCache and AzureBlobCache (and any others) would be ideal.

@ctolkien No problem, anything else you need to be made overridable?

@JimBobSquarePants Not as far as I'm aware, that looks like it will get the job done.

It occurs to me that if a new source file has a last-write-time that is older than the cached result then there is no way to tell if the image is new.

Hi Jim,

I had a similar issue when working on the Amazon S3 version of the cache.

What I was seeing is when using cloud files as source you'd get to IsUpdatedAsync line 462 and the RequestPath is relative (in my case was just the image name) so the check IsFile exceptions and you drop through to the exception. On the S3 Cache I've changed this line to read

if ((Uri.IsWellFormedUriString(this.RequestPath,UriKind.Absolute)) && (new Uri(this.RequestPath).IsFile))

May or may nor be relevant!

Thanks
Andy

Hey @AndyFelton

Thanks! I'll have a debug asap and see if it's the same issue.

I'll look at your PR asap also. 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bartmax picture Bartmax  路  8Comments

skttl picture skttl  路  5Comments

DocCaliban picture DocCaliban  路  4Comments

nul800sebastiaan picture nul800sebastiaan  路  7Comments

Leftyx picture Leftyx  路  5Comments