Solved

need help adding if modified since tag to my current .htaccess for proper caching

Posted on 2014-07-26
3
157 Views
Last Modified: 2014-10-18
have set up my .htaccess file using snippets of code from html5's boilerplate. however, if I update the content of lets say a css file, it doesn't update. I have to delete the actual cookie from my web browser to see changes. could you help me implement something with like: if-modified-since so that the browser would be able to tell that a file has changed and dispaly it

Here is my current .htaccess file:
# ------------------------------------------------------------------------------
# | ETag removal                                                               |
# ------------------------------------------------------------------------------

# Since we're sending far-future expires headers (see below), ETags can
# be removed: http://developer.yahoo.com/performance/rules.html#etags.

# `FileETag None` is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>

FileETag None

# ------------------------------------------------------------------------------
# | Expires headers (for better cache control)                                 |
# ------------------------------------------------------------------------------

# The following expires headers are set pretty far in the future. If you don't
# control versioning with filename-based cache busting, consider lowering the
# cache time for resources like CSS and JS to something like 1 week.

<IfModule mod_expires.c>

ExpiresActive on
ExpiresDefault                                      "access plus 1 month"

# CSS
ExpiresByType text/css                              "access plus 1 year"

# Data interchange
ExpiresByType application/json                      "access plus 0 seconds"
ExpiresByType application/xml                       "access plus 0 seconds"
ExpiresByType text/xml                              "access plus 0 seconds"

# Favicon (cannot be renamed!) and cursor images
ExpiresByType image/x-icon                          "access plus 1 week"

# HTML components (HTCs)
ExpiresByType text/x-component                      "access plus 1 month"

# HTML
ExpiresByType text/html                             "access plus 0 seconds"

# JavaScript
ExpiresByType application/javascript                "access plus 1 year"

# Manifest files
ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
ExpiresByType text/cache-manifest                   "access plus 0 seconds"

# Media
ExpiresByType audio/ogg                             "access plus 1 month"
ExpiresByType image/gif                             "access plus 1 month"
ExpiresByType image/jpeg                            "access plus 1 month"
ExpiresByType image/png                             "access plus 1 month"
ExpiresByType video/mp4                             "access plus 1 month"
ExpiresByType video/ogg                             "access plus 1 month"
ExpiresByType video/webm                            "access plus 1 month"

# Web feeds
ExpiresByType application/atom+xml                  "access plus 1 hour"
ExpiresByType application/rss+xml                   "access plus 1 hour"

# Web fonts
ExpiresByType application/font-woff                 "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
ExpiresByType application/x-font-ttf                "access plus 1 month"
ExpiresByType font/opentype                         "access plus 1 month"
ExpiresByType image/svg+xml                         "access plus 1 month"

</IfModule>

Open in new window

0
Comment
Question by:Lukas Mickevicius
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40221813
Most browsers always send an 'If Modified Since' with a request for 'normal caching'.  But you have your CSS file expiration set to a year.  That means that your browser is not going to check for a year after the file was put in the cache.  If you read the note starting on line 19 above, you need to change the file name if you want a new version of your CSS file to be downloaded.

If you are still designing the site, I would remove all of that until you are done.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use tracing facilities in your browser steps 2 117
Automatic Image Uploading 9 81
SQL to update characters in table column 6 125
Interview question Javascript, database 12 57
New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

785 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