In D7, I have a panel that contains a view that contains a jquery image slideshow.

Every day, the images that compose the slideshow are updated by a cron job---ie, every day's new images override the old ones (they are given the same names). So, say I have image1.png, image2.png and image3.png---every day these files are overwritten with new pictures.

I have added the following anti-cache protections in my meta section to both the page/panel and the view itself:

<meta http-equiv="Cache-Control" content="no-cache, must-revalidate"> 
<meta http-equiv="Pragma" content="no-cache"> 
<meta http-equiv="Expires" content="0"> 
<meta http-equiv="refresh" content="300"> 

I have also turned off all caching on the server of any duration, and of javascript/css. I also run the external cron with the cron-key after the image overwrite occurs.

Yet it seems that the only way my slideshow ever updates to reflect the new content of the image files is when I do an F5 or ctrl+r hard reload.

I don't want to ask my users to do this, so how can I force a reload and cache-clearing beyond the measures I've already taken above to get the browser to recognize that the images in the slideshow have changed on the server?

(I saw this recent similar post, How to tell if an image was updated, but it seems to apply to images created by Drupal, rather than created externally and pumped in.)


I have also added, in light of @mikeytown2's comment below, the following to my .htaccess file:

 # Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  # ExpiresDefault A1209600
  ExpiresDefault A600 #NOTE, this means ALL sites expire in 5 minutes by default!

  <FilesMatch \.php$>
    ExpiresActive Off


The .htaccess is in my public folder.

Even with this, which should be telling Drupal that all caches from my page expire at 5 minutes, I am still not seeing an update when new images replace old ones of the same name in my slideshow.

I have made sure to completely clear my cache and await an external cron, and the old images remain cached in the browser and/or server.

2 Answers 2


with firebugs net panel click on image1.png, select cache and get this information

Last Modified
Last Fetched

Your currently setting the html page to not be cached in the browser (which is already the case by default). If the images are hosted on your server, you need to adjust your apache .htaccess rules and have these images not be cached. Drupal's default htaccess uses a 2 week cache for everything other than php scripts. You need to make an exception for your images with filesmatch. Example:

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Match image1.png, image2.png, etc...
  <FilesMatch ^image\d+\.png$>
    # Disable browser caching.
    ExpiresActive Off

If the images are not hosted on your server simply append a question mark with the current unix time to the end of the image src. Example:

  • Awesome, thanks, that's very thorough. Can I ask for one other pointer though? I'm not very good with regular expressions, so if my images were instead named image_ABC.png, image_BBB.png, etc... would the following replacement be right? <FilesMatch ^image_[A-Z]+.png$> Oct 4, 2011 at 10:33
  • In full context, the .htaccess in my public directory now looks like this: <IfModule mod_expires.c> ExpiresActive On ExpiresDefault A1209600 <FilesMatch \.php$> ExpiresActive Off </FilesMatch> <FilesMatch ^image_[A-Z]+.png$> ExpiresActive Off </FilesMatch> </IfModule> And this is not working yet Oct 4, 2011 at 11:03
  • Did a little tinkering: it turns out even when I change A1209600 to A600, so it should release ALL caches within 5 minutes, it still isn't reflecting the new png files. So, there might be something beyond .htaccess at work here? Oct 4, 2011 at 18:49
  • mod_expires could be disabled on your server. What does firebug say the cache lifetimes of the files are?
    – mikeytown2
    Oct 5, 2011 at 1:05
  • As for regex, I use txt2re.com to help with creating regex given a string. This is a good start: txt2re.com/… Putting this all together you can test regex @ regexio.com/prototype.html (all back slashes here need to be double escaped \\; apache only needs one ) image_[A-Z]+.png should be image_[A-Z]+\.png
    – mikeytown2
    Oct 5, 2011 at 1:17

None of these internal-to-drupal settings worked. It turned out I had to curl my cron.php remotely to actually reset the caching.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.