cache busting with ir0

John Allan Apr 16, 2014 01:15PM PDT

Is there a way to bust the cache of a particular image on your ir0 service without changing the URL?

For instance I have http://www.website.com/headshot.jpg

I use your service for a few months.

Then I upload a new version of http://www.website.com/headshot.jpg because I shaved off my beard :)

Is there a way to clear your stored version of that particular image? I realize if I change the url to headshot-2.jpg that would work but what if I’ve used the original URL in static web content? In the CMS we’re using it makes much more sense to upload a new version of (replace) the same file as opposed to creating a new file.

Any input you might have would be greatly appreciated.

Regards.

John

Up -5 rated Down
Michael Apr 16, 2014 01:50PM PDT Mobify Agent

Hi John,

We’ve just added a brand new feature to Mobify.js version 1.3, which provides the ability to add a cacheBreaker key to the ‘options’ object that you pass into the Image Resizer .resizeImages() function (take a look at https://www.mobify.com/mobifyjs/docs/image-resizing/ for a refresher on Image Resizer if needed). Here’s the format of that new key:

cacheBreaker: <value which changes when you want to break cache>

For example, if you wanted to be fancy you might write something like this:

$(‘img’).resizeImages({ cacheBreaker: context.buildDate });

What this would do is dynamically insert the build date at time of pushing a bundle to Mobify Cloud. If you wanted to break the image cache you wouldn’t need to make any local code changes - simply push a new bundle and publish it. Please note that this feature literally is ‘brand new’ and as such, hasn’t undergone thorough testing with our own internal projects (so if you have bug reports – let us know on https://github.com/mobify/mobifyjs !)

If you are not currently using Mobify.js v1.3 or cannot upgrade your project, you have three options:
1) Upload the image with a new filename, and alter the URL of the image on your desktop site
2) Try using the ‘cacheHours’ key within your resizeImages() ‘options’ object (e.g. ‘cacheHours: 1’) which will flush your cache at an interval you set (minimum 1 hour)
3) Exclude this image from Image Resizer within the Konf

Hopefully that information helps. Let me know if you have further questions!

Cheers,
Michael

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)
support@mobify.me
https://cdn.desk.com/
mobify
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
Invalid characters found
/customer/en/portal/articles/autocomplete