ModPagespeed changes cache expiry time of non-rewritten resource to 5 minutes

258 views
Skip to first unread message

David Scherfgen

unread,
Aug 20, 2017, 4:18:58 AM8/20/17
to mod-pagespeed-discuss
Hello,

on my page, I have a CSS resource that's not being rewritten by ModPagespeed. That's OK and to be expected because I'm dynamically adding it using JavaScript.
Since that resource doesn't profit from ModPagespeed, I thought I'd set at least a long cache expiry time in the server configuration:

# ModPagespeed doesn't handle the mobile CSS. Set its cache expiry to one year.
<FilesMatch "^mobile-min\.css$">
Header set Cache-Control "max-age=31556926"
</FilesMatch>

Now when I request that CSS file with ModPagespeed disabled for the site, I get the expected response headers:

  1. Accept-Ranges:
    bytes
  2. Cache-Control:
    max-age=31556926
  3. Connection:
    Keep-Alive
  4. Content-Encoding:
    gzip
  5. Content-Length:
    1735
  6. Content-Type:
    text/css
  7. Date:
    Sun, 20 Aug 2017 08:15:09 GMT
  8. ETag:
    "bf063-1540-555f2c92a6a40"
  9. Keep-Alive:
    timeout=5, max=95
  10. Last-Modified:
    Fri, 04 Aug 2017 19:48:49 GMT
  11. Server:
    Apache
  12. Strict-Transport-Security:
    max-age=63072000; includeSubDomains; preload
  13. Vary:
    Accept-Encoding

Whereas with ModPagespeed enabled, I'm getting a cache expiry time of only 5 minutes:

  1. Cache-Control:
    max-age=300
  2. Connection:
    Keep-Alive
  3. Content-Encoding:
    gzip
  4. Content-Length:
    1754
  5. Content-Type:
    text/css
  6. Date:
    Sun, 20 Aug 2017 08:13:14 GMT
  7. Etag:
    W/"PSA-aj-VHDXSHSESP"
  8. Expires:
    Sun, 20 Aug 2017 08:18:14 GMT
  9. Keep-Alive:
    timeout=5, max=100
  10. Server:
    Apache
  11. Vary:
    Accept-Encoding
  12. X-Content-Type-Options:
    nosniff
  13. X-Original-Content-Length:
    5440

Do you have any idea why ModPagespeed overwrites my cache expiry time?

Thank you!

David Scherfgen

unread,
Aug 20, 2017, 4:35:07 AM8/20/17
to mod-pagespeed-discuss
Additional detail: I'm using a ModPagespeedLoadFromFileMatch directive, and it also applies to the CSS resource in question.
Could this be the reason why I'm getting that 5 minutes cache expiry time?

Otto van der Schaaf

unread,
Aug 20, 2017, 4:40:57 AM8/20/17
to mod-pagespeed-discuss
mod_pagespeed may send out short and conservative caching directives in the header when it is till working to finish computing the fully optimized resource.
If that is the case, you should see the large original expiry value after a couple of refreshes.
(note that images added dynamically via javascript are still processed/optimized by mod_pagespeed's In-Place Resource optimization [1]).

However, I suspect you are running into an issue that I think has been solved in the latest release (1.12.34.2), which involved LoadFromFile and resources that mod_pagespeed can't further improve upon. Upgrading should resolve the issue, or alternatively you could try excluding affected resources from being matched by the LoadFromFile configuration.


Otto

On Sun, Aug 20, 2017 at 10:35 AM 'David Scherfgen' via mod-pagespeed-discuss <mod-pagesp...@googlegroups.com> wrote:
Additional detail: I'm using a ModPagespeedLoadFromFileMatch directive, and it also applies to the CSS resource in question.
Could this be the reason why I'm getting that 5 minutes cache expiry time?

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/61d5d0a3-03f1-4a3a-ac48-5962df91fcfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Scherfgen

unread,
Aug 20, 2017, 5:31:42 AM8/20/17
to mod-pagespeed-discuss
Thanks for the quick response.
I am already using the latest version.
I was able to fix it by adding a "ModPagespeedLoadFromFileRuleMatch Disallow" directive.

Joshua Marantz

unread,
Aug 20, 2017, 8:07:47 AM8/20/17
to mod-pagespeed-discuss
The resolution you gave works, but also means that mod_pagespeed will not minify the CSS in-place, or optimize any backround image URLs in that CSS.  The reason that your cache-control headers were being ignored is that mod_pagespeed doesn't see them if it loads the resource directly from the file-system.

In 1.12 you can declare the TTL for such resources with

    ModPagespeedLoadFromFileCacheTtlMs implicit_cache_ttl_in_milliseconds


--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/52f4521a-d54d-4c6c-b59d-bec73cb31f6b%40googlegroups.com.

Luke Kenneth Casson Leighton

unread,
Aug 25, 2017, 9:17:32 AM8/25/17
to mod-pagesp...@googlegroups.com
On Sun, Aug 20, 2017 at 9:40 AM, Otto van der Schaaf <osc...@we-amp.com> wrote:

> However, I suspect you are running into an issue that I think has been
> solved in the latest release (1.12.34.2), which involved LoadFromFile and
> resources that mod_pagespeed can't further improve upon.

would symptoms of that involve things from the console like this:

Resources not rewritten because of restrictive Cache-Control headers: 68.81%
Cache misses: 36.22%
Cache lookups that were expired: 16.19%

despite having huge timeouts:

# set file cache ttl (ms) - 7*24*3600*1000
pagespeed LoadFromFileCacheTtlMs 604800000;
pagespeed ImplicitCacheTtlMs 604800000;

Kevin Nguyen

unread,
Aug 31, 2017, 7:28:29 AM8/31/17
to mod-pagespeed-discuss

pagespeed ImplicitCacheTtlMs 3600000000000;

pagespeed LoadFromFileCacheTtlMs 360000000000;


I had the same issue and finally this works for me. 

Luke Kenneth Casson Leighton

unread,
Aug 31, 2017, 2:32:42 PM8/31/17
to mod-pagesp...@googlegroups.com
On Thu, Aug 31, 2017 at 12:28 PM, Kevin Nguyen
<kevinng...@gmail.com> wrote:

> pagespeed ImplicitCacheTtlMs 3600000000000;
>
> pagespeed LoadFromFileCacheTtlMs 360000000000;
>
>
> I had the same issue and finally this works for me.

ok great i'll give that a shot, thanks kevin
Reply all
Reply to author
Forward
0 new messages