Nige-A Posted November 17, 2020 Share Posted November 17, 2020 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 More sharing options...
Fiber Posted November 18, 2020 Share Posted November 18, 2020 ctrl shift r works for me in both browsers Link to comment Share on other sites More sharing options...
♥14steve14 Posted November 18, 2020 Share Posted November 18, 2020 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 More sharing options...
sapguy Posted December 2, 2020 Share Posted December 2, 2020 <?php $randomnumber = rand(1, 99999); echo '<link rel="stylesheet" type="text/css" href="stylesheet.css?v='.$randomnumber.'">'; ?> This will do it Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.