0

I am keep seeing the old images that are referenced in CSS file. This image was changed more than two months ago. The only way to refresh the images is to open the store via incognito mode.

I thought it might be related to .htaccess file, however in .htaccess file it is set to expire the css file after 7 days and png image after 30 days.

ExpiresActive On
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"

In my CSS file I have an image path as below:

background: url(../../images/newsletter.png)

The "newsletter.png" in css will never change. It's the actual file on the server that get replaced with new png file.

Is there a way I could refresh this from the server side, so all the clients who are browsing the store get to see the latest visuals?

  • 1
    I'm afraid, you'll have to go for some sort of versioning - i.e. described here: stackoverflow.com/questions/7671168/…. - since even if you for example change the image name and update your css you still can not be sure that an user's browser that has visited your page would fetch the updated css file. – Christoph Farnleitner Jan 13 '18 at 12:47
  • I'm sorry but I don't quite understand your edit. Are you talking about changes in css i.e. from background: url(../../images/newsletter.png) to background: url(../../images/newsletter-new.png) or is it a change 'within' the file newsletter.png (i.e. a new icon/image)? – Christoph Farnleitner Jan 13 '18 at 12:53
  • @Christoph, Yes, my edit was confusing. What I mean is that the file name in the css file will NEVER change. It is the actual file on the server that gets replaced with new png file but same name. – Benjamin Jan 13 '18 at 13:00
  • 1
    well then, background: url(../../images/newsletter.png?v=20180113) should be working as long as your stylesheet gets reloaded. When the file changes the next time just again change the "made up" version param. For better results however a similar approach on the stylesheet itself might be necessary as well. – Christoph Farnleitner Jan 13 '18 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.