Solved

How to update files using FilesMatch .htaccess max-age=

Posted on 2014-01-07
5
582 Views
Last Modified: 2014-01-16
Hi,

If I'm using the following to cache my javascript and CSS files:

<FilesMatch "\.(js|css)$">
  FileETag -INode MTime Size
  Header set Cache-Control "max-age=604800, public, must-revalidate"
</FilesMatch>

Open in new window


And I'm updating my files and changing the code then how do I reset the cache? Is there a better way to set the cache of javascript and CSS or image files while having the versatility of updating the code and seeing the updates immediately by simply using CTL+F5?

Thank you,
Victor
0
Comment
Question by:Victor Kimura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 51

Assisted Solution

by:Steve Bink
Steve Bink earned 500 total points
ID: 39765360
As I understand it, the must-revalidate directive should handle this for you.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.4
0
 

Assisted Solution

by:Victor Kimura
Victor Kimura earned 0 total points
ID: 39772147
Hmmm...ok.

It states "(I.e., the cache MUST do an end-to-end revalidation every time, if, based solely on the origin server's Expires or max-age value, the cached response is stale.)"

But it's still not really clear if, say, a particular js file is less than the max-age value or Expires value then will the client still receive the latest file that I just uploaded?

There is something I read from Google about URL fingerprinting but looks more complicated. The option they suggested is:

Another strategy is to create a new release directory for each new version of the application and put all the assets for each version in the versioned directory. This has the drawback that if an asset doesn't change between versions, its URL will still change forcing a re-download. Using content hashes does not suffer from this problem but is slightly more complex.

https://developers.google.com/speed/docs/insights/LeverageBrowserCaching

I guess the file-append-date-time.js may work in this case.

But I'm wondering if anyone has any suggestions other than the one Google posted.
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 39772950
Based on your Google reference, I think that would be option you need.  If the browser is not going to issue a GET until the expiry/age has been reached, it will never know about your newly modified file.  

If you need this for only a file or two, I would use the fingerprinting method.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 39774335
No points.  You found the answer...I just agreed with it. :)
0
 

Author Closing Comment

by:Victor Kimura
ID: 39784871
Ok, thank you, @routinet! =)
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question