Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-07
5
Medium Priority
?
590 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 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

721 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