0

I'm looking for an efficient way to control browsers cache for all links (CSS) and scripts in each page based on file (or module) version. I want every browser to look file's version first (in it's location), if it's still the same version, use cache but if it's version has been changed, reload the file.

If i use current file version (or it's module) as a query string in the end of file's location, browser (Specially Firefox) won't use cache for this file, even it's same as previous request and server return a 304 header. so it's impact loading performance.

for example:

<link rel="stylesheet" type="text/css" media="all" href="Modules/Footer/view/css/footer.css?version=1.01">

I don't want to change file's physically location based on it's version because file existed in a static location and it's version changed based on some update in it's module.

for example:

<link rel="stylesheet" type="text/css" media="all" href="Modules/Footer/1.01/view/css/footer.css">

to:

<link rel="stylesheet" type="text/css" media="all" href="Modules/Footer/1.02/view/css/footer.css">

It will worked but it's not what I'm looking for.

DarkMaze
  • 263
  • 3
  • 15
  • Sounds more like a bug in Firefox. Wait... what? The server is returning a 304? That sounds like [exactly what you want](http://stackoverflow.com/a/20978279/791010). – James Thorpe Jun 19 '15 at 12:23
  • I know, but how to fix that? – DarkMaze Jun 19 '15 at 12:25
  • I've seen this behaviour before when we had unusual characters in the URL - parentheses I think it was. They were triggering some out-of-spec heuristic whereby the browser refused to cache them. We changed the format of the URLs to only use "normal" characters, and the browser started caching them. (Sorry I can't remember the exact details.) – RichieHindle Jun 19 '15 at 12:26

0 Answers0