Solved

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

Posted on 2014-01-07
5
570 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 50

Assisted Solution

by:Steve Bink
Steve Bink earned 500 total points
Comment Utility
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
Comment Utility
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 50

Accepted Solution

by:
Steve Bink earned 500 total points
Comment Utility
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 50

Expert Comment

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

Author Closing Comment

by:Victor Kimura
Comment Utility
Ok, thank you, @routinet! =)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now