Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

PageSpeed output resources cannot be cached in Google Cloud #1149

Closed

Description

@JoyceBabu

Currently pagespeed adds Cache-Control:max-age=31536000 to optimized resources. Is it possible to add public to it?

Google CDN (alpha) requires 'Cache-Control: public' to be present for resources that must be cached.

Activity

  1. jmarantz commented on Mar 11, 2016

    @jmarantz
    Contributor

    Hi -- I'm getting some clarification from some people that know more about
    the CDN.

    On Fri, Mar 11, 2016 at 6:35 AM, Joyce Babu notifications@github.com
    wrote:

    Currently pagespeed adds Cache-Control:max-age=31536000 to optimized
    resources. Is it possible to add public to it?

    Google CDN (alpha) requires 'Cache-Control: public' to be present for
    resources that must be cached.

    —
    Reply to this email directly or view it on GitHub
    #1149.

  2. jmarantz commented on Mar 12, 2016

    @jmarantz
    Contributor

    Adding "public" to the cache-control value is a requirement for Google CDN, but is not required by the HTTP spec. https://cloud.google.com/compute/docs/load-balancing/http/cdn describes the Google requirements, which are pretty clear.

    To meet these without adding an unnecessary qualifier for other caches, we can gate this logic on the presence of response-header
    Via: 1.1 google

  3. jmarantz commented on Mar 12, 2016

    @jmarantz
    Contributor

    Joyce: is it possible for you to add a workaround for this problem in your nginx config? That might help you get better behavior until we can add this functionality to a PageSpeed release.

  4. JoyceBabu commented on Mar 12, 2016

    @JoyceBabu
    Author

    I tried disabling all rewriting rules, and using add_header 'Cache-Control' public;. This resulted in two Cache-Control headers

    Cache-Control:max-age=604800
    Cache-Control: public
    

    Google CDN did not cache those resources, even though it is technically equivalent to Cache-Control:max-age=604800, public

    To meet these without adding an unnecessary qualifier for other caches, we can gate this logic on the presence of response-header

    Did you mean request-header?

    Joyce: is it possible for you to add a workaround for this problem in your nginx config? That might help you get better behavior until we can add this functionality to a PageSpeed release.

    I am unable to modify the Cache-Control headers from nginx config. I tried using POSITION_AUX=true, still I am unable to modify the headers. I remember seeing a comment by Jeff in another issue that nginx location blocks targeting optimized resources doesn't work when LoadFromFile is enabled.

  5. jmarantz commented on Mar 12, 2016

    @jmarantz
    Contributor

    Yes I meant the Via request-header :)

    there is not an nginx equivalent to apache's "header set" directive?

    On Sat, Mar 12, 2016 at 3:37 AM, Joyce Babu notifications@github.com
    wrote:

    I tried disabling all rewriting rules, and using add_header
    'Cache-Control' public;. This resulted in two Cache-Control headers

    Cache-Control:max-age=604800
    Cache-Control: public

    Google CDN did not cache those resources, even though it is technically
    equivalent to Cache-Control:max-age=604800, public

    To meet these without adding an unnecessary qualifier for other caches, we
    can gate this logic on the presence of response-header

    Did you mean request-header?

    Joyce: is it possible for you to add a workaround for this problem in your
    nginx config? That might help you get better behavior until we can add this
    functionality to a PageSpeed release.

    I am unable to modify the Cache-Control headers from nginx config. I tried
    using POSITION_AUX=true, still I am unable to modify the headers. I
    remember seeing a comment by Jeff in another issue that nginx location
    blocks don't when LoadFromFile is enabled.

    —
    Reply to this email directly or view it on GitHub
    #1149 (comment)
    .

  6. JoyceBabu commented on Mar 12, 2016

    @JoyceBabu
    Author

    there is not an nginx equivalent to apache's "header set" directive?

    Yes, there is the add_header directive and the more_set_headers directive. But from what I understand, the header filter appears before ngx_pagespeed in the nginx filter chain. Hence, headers are always intercepted and modified by ngx_pagespeed.

    Setting the (experimental) environment variable POSITION_AUX=true is supposed to move ngx_pagespeed's position, so that it will be possible to modify the headers from nginx config. I just found out that it was not working because a change introduced for nginx 1.9.11+ had broken that option. After fixing it, now I am able to do more_set_headers "Cache-Control: max-age=31536000, public";

    Thank you.

  7. jmarantz commented on Mar 12, 2016

    @jmarantz
    Contributor

    Glad you found a workaround, but I want to leave this open till we fix it properly.

  8. self-assigned this
    on Jun 7, 2016
  9. jmarantz commented on Jun 16, 2016

    @jmarantz
    Contributor

    This auto-closed when I subbmitted the partial fix: apache/incubator-pagespeed-mod@6d81e80

    This fix propagates cache-control:public from origin resources to rewritten resources. However, it does not infer that we need cache-control:public when running inside GCE, which it can do with the "Via" request header, if that includes the substring 'google'.

  10. 2 remaining items

  11. dhirenpratap commented on Jun 29, 2016

    @dhirenpratap

    Can wait for it. Thanks for the hard work.

  12. changed the title [-]Set Cache-Control: public on pagespeed optimized resources[/-] [+]Set Cache-Control: public on pagespeed optimized resources when running in Google cloud[/+] on Aug 2, 2016
  13. justbeez commented on Aug 5, 2016

    @justbeez

    Thanks for the effort on this @jmarantz @crowell!

    We've been running into the same issues with Cloud CDN on the mod_pagespeed side and trying to come up with workaround based on where this hooks in our chain—and I'm glad to have found this issue over on the ngx_pagespeed tracker.

    I see that about a month and a half ago that there wasn't a date for this to roll out yet—does anyone know if there's a window scheduled for an upcoming release? I haven't seen one in quite a while, so I'm mostly just trying to figure out if it's worth building trunk or if my laziness will pay off ;)

    Thanks again all!

  14. crowell commented on Aug 9, 2016

    @crowell
    Contributor

    We're working on getting the release rolled out this week. We'll make an announcement on the mailing lists when it is available.

  15. changed the title [-]Set Cache-Control: public on pagespeed optimized resources when running in Google cloud[/-] [+]PageSpeed output resources cannot be cached in Google Cloud[/+] on Aug 12, 2016
  16. olekstumedia commented on Aug 16, 2016

    @olekstumedia

    Any update on this? We really need that new version of ngx_pagespeed module((
    GoogleCDN will not work for the all servers that use pagespeed))) This is contradictorily assuming that pagespeed is also related/mainteined by Google company.

  17. morlovich commented on Aug 16, 2016

    @morlovich
    Contributor

    New version with a fix just got released earlier today:
    https://groups.google.com/forum/#!topic/ngx-pagespeed-discuss/flIW0eAdVFw

  18. justbeez commented on Aug 19, 2016

    @justbeez

    Just a note for those looking for this on the mod_pagespeed site, this is available in the 1.11.33.3-beta version announced here:
    https://groups.google.com/forum/#!topic/mod-pagespeed-announce/UMCmeItofcY

  19. nathanjosiah commented on May 31, 2017

    @nathanjosiah

    Any update on this issue? I see that a few versions have been released with a fix for this for both Apache and nginx but I am still unable to change the Cache-Control header for HTML responses. The only resource I can find about the Cache-Control header still being set is on the Configuring Downstream Caches page but this won't work for the Google Cloud CDN because the CDN doesn't allow the required configuration such as the PS-Capability header or the purge URL's.

  20. jmarantz commented on May 31, 2017

    @jmarantz
    Contributor

    This was fixed a long time ago in apache/incubator-pagespeed-mod@c8dc73f and was released in 1.11, which is marked as stable.

    However, if you are talking about HTML responses, then this bug is not related to that at all. Note that caching HTML responses with ngx_pagespeed means you cannot enable any user-agent specific optimizations (e.g. webp transcoding). If that's acceptable, configure ModifyCachingHeaders ( https://modpagespeed.com/doc/configuration#ModifyCachingHeaders) and then NPS will just leave your headers alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions