When I consulted page speed I scored a 77. On the section for
leverage browser caching "The following resources are missing a cache
expiration..." there is a list of all the images on the page.
I tried to make an .htaccess file with specific expiration dates and
also with the 1 month after access date and uploaded to my image
subdirectory.
<FilesMatch “\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$”>
Header set Cache-Control “max-age=2419200, public”
</FilesMatch>
In all cases this resulted in no images appearing on the pages at
all.
I have tried a number of other versions that appear in these
discussions
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|js|css)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header unset Last-Modified
</FilesMatch>
# Asset Expiration
ExpiresActive On
<FilesMatch "\.(ico|gif|jpe?g|png|js|css)$">
ExpiresDefault "access plus 1 year"
</FilesMatch>
And still the same issue occurs when I put the htaccess in my
subdirectory, any idea what am I doing wrong? Is there another way to
deal with this issue? Thanks for your help.
For most accurate results in cases like these, I suggest clearing the
browser cache, quitting the browser, then restarting the browser with
a fresh empty cache.
> --
> You received this message because you are subscribed to the Google Groups "page-speed-discuss" group.
> To post to this group, send email to page-spee...@googlegroups.com.
> To unsubscribe from this group, send email to page-speed-disc...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/page-speed-discuss?hl=en.
>
>
> > For more options, visit this group athttp://groups.google.com/group/page-speed-discuss?hl=en.- Hide quoted text -
>
> - Show quoted text -
I also think that the following code is easier to maintain (you can
have a jpg image generated by php)
ExpiresActive On
ExpiresByType image/gif A2678400 # 31 days = OK for
page speed
ExpiresByType image/png A2678400
ExpiresByType image/jpeg A2678400
ExpiresByType text/css A2678400
ExpiresByType application/javascript A2678400
ExpiresByType application/x-javascript A2678400
...
Whatever you want
> > > For more options, visit this group athttp://groups.google.com/group/page-speed-discuss?hl=en.-Hide quoted text -
> > > > For more options, visit this group athttp://groups.google.com/group/page-speed-discuss?hl=en.-Hidequoted text -
>
> > > - Show quoted text -- Hide quoted text -
Actually, It's quite logical, I've seen many website with static files
older than one year...
Then you know what you have to do.
> > > > > For more options, visit this group athttp://groups.google.com/group/page-speed-discuss?hl=en.-Hidequotedtext -
Please let me know.
Am I need add this into the end of .htaccess file and change A2678400
to A32140800 ?
Thx, Vitaly
> > > > For more options, visit this group athttp://groups.google.com/group/page-speed-discuss?hl=en.-Hidequoted text -
The Apache config you linked to contains other problems too. For
example, it caches .ICO files for 10 years. Want to change your
Favicon? Well now you cannot.
I cannot stress enough that a most performance optimizations are not
something that you can do without a plan or process in place or
without coordinating with all the people involved with the design,
development and operations of a web site. Otherwise you end up with
problems and inconsistency.
Billy Hoffman
--
http://zoompf.com/
And yes, i'm aware that if this is big site then you should inform all
the people responsible for it.
This is an important point. Caching should only be enabled for
content that will not change. In our docs, we recommend
fingerprinting.
From http://code.google.com/speed/page-speed/docs/caching.html :
"""
Use fingerprinting to dynamically enable caching.
For resources that change occasionally, you can have the browser cache
the resource until it changes on the server, at which point the server
tells the browser that a new version is available. You accomplish this
by embedding a fingerprint of the resource in its URL (i.e. the file
path). When the resource changes, so does its fingerprint, and in
turn, so does its URL. As soon as the URL changes, the browser is
forced to re-fetch the resource. Fingerprinting allows you to set
expiry dates long into the future even for resources that change more
frequently than that. Of course, this technique requires that all of
the pages that reference the resource know about the fingerprinted
URL, which may or may not be feasible, depending on how your pages are
coded.
"""
Perhaps the Page Speed caching rule should explicitly warn about this,
instead of just linking to documentation.
Sam
Actually, the best solution is to put a version number for all your
files header-1.0.jpg for example, or something like (in php)
header.jpg?<?php echo filemtime('header.jpg');?>.
Then, you can put a very far future expiration date (5, 10, 20 years)
there's no matter.
The important thing is to understand that page speed is not a teacher
giving you a mark, but a workmate giving you advices.
> > > > > For more options, visit this group athttp://groups.google.com/group/page-speed-discuss?hl=en.-Hidequotedtext -