Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

CSS forced reload


Nige-A

Recommended Posts

CSS forced reload

I was having a lot of trouble getting Edge (with chrome core) and Chrome to reload css after making changes. Even to the point of deleting and replacing the css file and still no luck.
After searching, I found this site. Original source link below.

Quote

The solution!

Requesting file.css and file.css?rnd=23 will get you the contents of the same file but those two requests are not the same! Both the browser and the server see them as requests for two different resources. That’s the whole premise behind our solution. Credits for it go to Paul Irish who wrote about the method back in 2008.

With the magic of a few lines of JavaScript, we find all CSS files referenced on the page (all <link rel="stylesheet"> elements) and then change their URLs. Changing /some-path/style.css to /some-path/style.css?rnd=132 forces the browser to re-request the file from the server. Because of the rnd part, neither the browser or the server have that request in the cache and are forced to grab a fresh copy of the file! Simple, fast, universal and clean solution!

I post here in case it helps others.
Apologies if this is not the right thing to do. Admins can delete if necessary.

Original source

Link to comment
Share on other sites

If you are doing this on a live or test site on your hosting, have you looked to see whether they are caching the content. You may have to clear the cache on your hosts. If you hace cpanel its easy there.

REMEMBER BACKUP, BACKUP AND BACKUP

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...