cache & godaddy server

1,121 views
Skip to first unread message

joe van winkle

unread,
Jun 15, 2011, 12:27:42 AM6/15/11
to mod-pagespeed-discuss
i manage a site (http://www.matthewsgalleries.com) and it is hosted on
godaddy. i have had problems enabling cache through .htaccess. the
problem is i do want to cache all files but html (or have a very short
life for html).

any suggestions?

Joshua Marantz

unread,
Jun 15, 2011, 1:06:08 AM6/15/11
to mod-pagespeed-discuss
Yes.  You can put this text in your .htaccess:

   <FilesMatch "\.(jpeg|jpg|png|gif|css|js)$">
     Header set Cache-control "max-age=600"
   </FilesMatch>

   <FilesMatch "\.(html|htm)$">
     Header unset Etag
     Header set Cache-control "max-age=0, no-cache, no-store"
     Header unset Last-Modified
   </FilesMatch>


Is that what you are looking for?  Note that mod_pagespeed is not currently enabled on your site.  Adding:

   ModPagespeed on

will do that.
-Josh

joe van winkle

unread,
Jun 15, 2011, 4:50:57 AM6/15/11
to mod-pagespeed-discuss
thanks joshua! (which is also my son's name)

here's what i have so far in my .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST}
^matthewsgalleries\.com [nc]
RewriteRule (.*) http://www.matthewsgalleries.com/$1 [R=301,L]
ErrorDocument 404 /assests/404.html
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/
javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIEs(7|8) !no-gzip !gzip-only-text/html
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters make_google_analytics_async,
rewrite_javascript, rewrite_images, collapse_whitespace,
elide_attributes, extend_cache
<FilesMatch "\.(jpeg|jpg|png|gif|css|js)$">
Header set Cache-control "max-age=7776000"
</FilesMatch>
<FilesMatch "\.(html|htm)$">
Header unset Etag
Header set Cache-control "max-age=0, no-cache, no-store"
Header unset Last-Modified
</FilesMatch>
</IfModule>

does any or all of the FilesMatch need to be in the IfModule?

thanks for your help!


On Jun 14, 10:06 pm, Joshua Marantz <jmara...@google.com> wrote:
> Yes.  You can put this text in your .htaccess:
>
>    <FilesMatch "\.(jpeg|jpg|png|gif|css|js)$">
>      Header set Cache-control "max-age=600"
>    </FilesMatch>
>
>    <FilesMatch "\.(html|htm)$">
>      Header unset Etag
>      Header set Cache-control "max-age=0, no-cache, no-store"
>      Header unset Last-Modified
>    </FilesMatch>
>
> Is that what you are looking for?  Note that mod_pagespeed is not currently
> enabled on your site.  Adding:
>
>    ModPagespeed on
>
> will do that.
> -Josh
>

Joshua Marantz

unread,
Jun 15, 2011, 8:52:45 AM6/15/11
to mod-pagespeed-discuss
Thanks for pasting your .htaccess file.  I found a couple of small issues which can easily be fixed :)

make_google_analytics_async is supported by mod_pagespeed but it was added after Go Daddy released.  Go Daddy has not yet upgraded the version of mod_pagespeed they are using.  You can tell what version of mod_pagespeed is in use by looking at the response-headers in Firebug.  For awkwardfamilyphotos.com this header is included:
      X-Mod-Pagespeed  0.9.15.4-423
On a site with an up-to-date mod_pagespeed you'll see this:
      X-Mod-Pagespeed  9.17.7-716

Next, you have spaces in your ModPagespeedEnableFilters line.  The list of filters should be comma-separated, but without spaces.

Finally, by setting your cache max-age to 7776000 you have made it hard for yourself to update css and js files.  If you set it to something more like 10 minutes (max-age=600) then mod_pagespeed will extend the cache lifetime for a year, but will do a server-side check every 10 minutes to see if the files have been updated.  This is the value of the extend_cache filter: to provide  long cache lifetimes to browsers will giving you the ability to update your site.

None of those FilesMatch directives need to be in the IfModule.

-Josh

joe van winkle

unread,
Jun 15, 2011, 9:13:13 AM6/15/11
to mod-pagespeed-discuss
ok changed to

<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedRewriteLevel PassThrough
ModPagespeedEnableFilters
rewrite_javascript,rewrite_images,collapse_whitespace,elide_attributes,extend_cache
</IfModule>
<FilesMatch "\.(jpeg|jpg|png|gif|css|js|ico)$">
Header set Cache-control "max-age=600"
</FilesMatch>
<FilesMatch "\.(html|htm|)$">
Header unset Etag
Header set Cache-control "max-age=600, no-cache, no-store"
Header unset Last-Modified
</FilesMatch>

will test later tonight

is there even a need for the ifmodule if we know that the mod is
installed?

any chance of godaddy upgrading the mod?

thanks for you help!

On Jun 15, 5:52 am, Joshua Marantz <jmara...@google.com> wrote:
> Thanks for pasting your .htaccess file.  I found a couple of small issues
> which can easily be fixed :)
>
> make_google_analytics_async is supported by mod_pagespeed but it was added
> after Go Daddy released.  Go Daddy has not yet upgraded the version of
> mod_pagespeed they are using.  You can tell what version of mod_pagespeed is
> in use by looking at the response-headers in Firebug.  For
> awkwardfamilyphotos.com this header is included:
>       X-Mod-Pagespeed  0.9.15.4-423
> On a site with an up-to-date mod_pagespeed you'll see this:
>       X-Mod-Pagespeed  9.17.7-716
>
> Next, you have spaces in your ModPagespeedEnableFilters line.  The list of
> filters should be comma-separated, but without spaces.
>
> Finally, by setting your cache max-age to 7776000 you have made it hard for
> yourself to update css and js files.  If you set it to something more like
> 10 minutes (max-age=600) then mod_pagespeed will extend the cache lifetime
> for a year, but will do a server-side check every 10 minutes to see if the
> files have been updated.  This is the value of the extend_cache filter: to
> provide  long cache lifetimes to browsers will giving you the ability to
> update your site.
>
> None of those FilesMatch directives need to be in the IfModule.
>
> -Josh
>
> On Wed, Jun 15, 2011 at 4:50 AM, joe van winkle <rip97...@gmail.com> wrote:
>
>
>
>
>
>
>
> > thanks joshua! (which is also my son's name)
>
> > here's what i have so far in my .htaccess
>
> > RewriteEngine On
> > RewriteCond %{HTTP_HOST}
> > ^matthewsgalleries\.com [nc]
> > RewriteRule (.*)http://www.matthewsgalleries.com/$1[R=301,L]

Joshua Marantz

unread,
Jun 15, 2011, 9:39:18 AM6/15/11
to mod-pagespeed-discuss
On Wed, Jun 15, 2011 at 9:13 AM, joe van winkle <rip9...@gmail.com> wrote:
ok changed to
....
<FilesMatch "\.(html|htm|)$">
 Header unset Etag
 Header set Cache-control "max-age=600, no-cache, no-store"

If you want your html to be max-age=600 then you need to remove the ", no-cache, no-store" attributes.  Note that mod_pagespeed will remove these anyway as mod_paegspeed-generated HTML is not currently cacheable.

is there even a need for the ifmodule if we know that the mod is
installed?

No -- it's just best practice when writing apache configs. 

any chance of godaddy upgrading the mod?

Yes -- and increasing the volume of requests from their customers can only help them in that direction.

thanks for you help!
 
no problem!

-Josh
 

joe van winkle

unread,
Jun 15, 2011, 9:54:26 AM6/15/11
to mod-pagespeed-discuss
ok final time?
i want longer cache for the pics so i changed it to:

<FilesMatch "\.(jpeg|jpg|gif|ico)$">
Header set Cache-control "max-age=2592000"
</FilesMatch>
<FilesMatch "\.(html|htm|css|js)$">
Header unset Etag
Header set Cache-control "max-age=600"
Header unset Last-Modified
</FilesMatch>

On Jun 15, 6:39 am, Joshua Marantz <jmara...@google.com> wrote:

Joshua Marantz

unread,
Jun 17, 2011, 7:20:17 AM6/17/11
to mod-pagesp...@googlegroups.com
So the configuration below you have is OK.  But note that mod_pagespeed will extend cache lifetime of images/css/js to 1 year.  It uses the origin timeout -- what you put in the htaccess file -- to determine how frequently to freshen mod_pagespeed's internal cache.

Also note that mod_pagespeed does not cache-extend unless you already have it set to 31 days or more.  You've got it set to 30 days, so we mod_pagespeed will cache extend the images to 1 year.

Given this htaccess file you'll see this behavior:

file-type    freshen internal        cache-control served to user

image        30 days                 1 year
css          10 minutes              1 year
js           10 minutes              1 year
html         always fresh            nocache

So the effect of setting the long TTL on your images is that mod_pagespeed will freshen its cache less frequently.  That wil slightly reduce the load on mod_pagespeed but won't affect the output.

We recommend 10 minute cache lifetimes for the origin just so that you can update resources and propagate them to the world in a bounded amount of time.  But the configuration you have is fine.

-Josh

Jan-Willem Maessen

unread,
Jun 17, 2011, 9:56:58 AM6/17/11
to mod-pagesp...@googlegroups.com
On Fri, Jun 17, 2011 at 7:20 AM, Joshua Marantz <jmar...@google.com> wrote:
Also note that mod_pagespeed does not cache-extend unless you already have it set to 31 days or more.  You've got it set to 30 days, so we mod_pagespeed will cache extend the images to 1 year.

I believe what Josh meant to say here is "mod_pagespeed does not cache_extend if you already have it set to 31 days or more".

-Jan-Willem Maessen

Joshua Marantz

unread,
Jun 17, 2011, 10:00:50 AM6/17/11
to mod-pagesp...@googlegroups.com

Yes.   Thank Jan!

sent from my android

Reply all
Reply to author
Forward
0 new messages