Chrome keeps caching my files — is there a way to disable cache on my website? | Sololearn: Learn to code for FREE!
+ 1

Chrome keeps caching my files — is there a way to disable cache on my website?

Chrome keeps caching my files, especially JS files. I can disable cache on my side sometimes, and or clear caches to get around that. But I can’t be telling to “clear cache” to every user that comes to my website. :: The problem with the files being cached: When I make changes to an [html, css, JS] code, it takes a while to see the changes on the website. Because it’s (chrome—caches) still holding on the previous changes. I want to make sure that the website updates as within seconds when I click on “save changes”.

16th Mar 2021, 10:24 PM
Ginfio
Ginfio - avatar
7 Antworten
+ 3
Martin Taylor usually cache are limited in size, and older/less used files are deleted from it ;P appending a query string with the date/hour (?date=202103170549) should do the trick in major of cases... however, reloading javascript file without refreshing page doesn't works ^^
17th Mar 2021, 4:51 AM
visph
visph - avatar
+ 2
Incognito mode in Chrome gives you the choice to browse the Internet without your activity being saved to your browser or device. Incognito mode doesn't use your existing cookie store and, at the end of the session, dumps any cookies, history, and autofill data that were generated
17th Mar 2021, 12:05 AM
CalviŐČ
CalviŐČ - avatar
+ 2
You dont need to worry about the cache growing, the browser will take care of it itself. visph answer is also a valid option, however in that case you completely disable caching, which may not be what you want. changing the filenames allows the file to be read from cache if the user reloads the page, and forces a reload if there were changes
17th Mar 2021, 7:25 AM
John Doe
+ 1
I’m wondering if this is something we can control with .htaccess or in some other way.
16th Mar 2021, 10:25 PM
Ginfio
Ginfio - avatar
+ 1
you can change the filename of the relevant files. bundlers like webpack usually generate a new filename on each build, eg main_4213674312.js
16th Mar 2021, 11:43 PM
John Doe
- 2
I use opera Gx you should use it too it's even more faster and better than that ram sucking chrome
17th Mar 2021, 5:08 PM
𝖆𝖊𝖙𝖍𝖊𝖗
𝖆𝖊𝖙𝖍𝖊𝖗 - avatar