?
Solved

Imporving Leverage Browser Caching

Posted on 2013-11-25
1
Medium Priority
?
320 Views
Last Modified: 2013-11-25
I need to improve my leverage browser caching.  I have this exact code in my htaccess file but it does not seem to be effective.  Plus, I see this code written differently all over the web.  Ie. some have # in front and some don't. Others use different coding, etc...

How exactly should my code look like.  See below.

<IfModule mod_expires.c>
  #ExpiresActive On
  #ExpiresByType image/gif "now plus 9 years"
  #ExpiresByType image/jpg "now plus 9 years"
  #ExpiresByType image/png "now plus 9 years"
  #ExpiresByType image/x-icon "now plus 9 years"
  #ExpiresByType text/html "now plus 9 days"
  #ExpiresByType text/txt "now plus 9 days"
  #ExpiresByType text/css "now plus 20 days"
  #ExpiresByType text/js "now plus 9 years"
  #ExpiresByType image/ico "now plus 30 days"
  #ExpiresByType application/javascript "now plus 2 weeks"
  #ExpiresByType application/x-javascript "now plus 2 weeks"
</IfModule>
0
Comment
Question by:livewirewebsolutions
1 Comment
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1400 total points
ID: 39675279
The '#' in the first column makes it a 'comment', not a command.  Here's the manual page from Apache:  http://httpd.apache.org/docs/2.2/mod/mod_expires.html

Note that even without the comment tags, those directives have no effect on items already in the browser cache because that info is only passed when the file is delivered from the server.

There is also a sentence in the fourth paragraph on that page that says those directives will not replace any commands that are already present in the response.

And last, those commands do not over-ride what the user has set in their browser.  If they set their cache to expire in 3 days, that's what will happen.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 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