0

I'm using mod_pagespeed with mod_cache.

When mod_pagespeed is off and mod_cache is off I see the following header:

cache-control:public,max-age=7200,must-revalidate

When mod_pagespeed is on and mod_cache is off, I see the following header on the response:

cache-control:max-age=0, no-cache, must-revalidate

As expected pagespeed has rewritten the cache-control.

However, when mod_pagespeed is on and mod_cache is on I see the following:

cache-control:public,max-age=7200,must-revalidate

According to the docs:

"By default, PageSpeed serves all HTML with Cache-Control: no-cache, max-age=0 because the transformations made to the page may not be cacheable for extended periods of time."

Why is the html being served as cacheable when mod_pagespeed and mod_cache is enabled?

DD.
  • 3,254

2 Answers2

1

There appears to be a bug when running mod_pagespeed 1.11.33.2-0 with Apache Httpd 2.4.23 running mod_cache.

For some reason mod_pagespeed does not rewrite the cache headers which leaves the html publically cacheable.

The workaround I used was to have virtualhost on port 81 running as a caching server with no pagespeed.

<VirtualHost *:81>
ProxyPass / ajp://tomcat-ipaddress:8009/
ProxyPassReverse / https://final-hostname/
ModPagespeed off
RemoteIPHeader X-Forwarded-For
CacheEnable disk /
CacheHeader on
</VirtualHost>

On virtualhost 443 or 80, you can then proxy the host on 81.

 <VirtualHost _default_:443>
 ProxyPass / http://localhost:81/
 ProxyPreserveHost On
 ModPagespeed on
 ProxyPassReverse / https://final-hostname/
DD.
  • 3,254
-1

Because by default mod_cache runs in quick handler mode:

http://httpd.apache.org/docs/current/mod/mod_cache.html#cachequickhandler

which means it touches the response "last", after mod_pagespeed has performed its transformations.

Use the

CacheQuickHandler off
AddOutputFilterByType ... 

example to order filters as appropriate.

Jonah Benton
  • 1,252