Solved

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

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

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 50

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 50

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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to enable sync between two yum repo? 1 54
windows 7 starter missing password 21 99
SMB share across internet 15 80
trouble on installing syslog-ng on CentOS 7 7 96
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é.
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

763 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