Question

I asked a question on what is style.css?ver=1 tag?. I learned that developers use style.css?ver=1 to let browsers read updated css, but W.Craig Trader pointed out that is is not good.

My question is, what is the best way to force a browser to read updated css without style.css?Ver=1 format?

Was it helpful?

Solution

Your server should take care of it. It will tell the browser when the file was last modified, and if the browser's cache is out of date, it will download the new version.

More in depth, each time the page loads, the browser does a head request on each item in the page (stylesheets, images..), which the webserver responds to by only sending the HTTP headers without the body, there is a header that specifies when the file was last modified (and possibly more about cache control), and if the browser's cache has a version of the file older than what the webserver says it has, it reloads that content.

OTHER TIPS

An option is to version the filename, like style-1.1.css.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top