Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-01-07
5
Medium Priority
?
596 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
  • 3
  • 2
5 Comments
 
LVL 51

Assisted Solution

by:Steve Bink
Steve Bink earned 2000 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

972 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