incubator-pagespeed-ngx icon indicating copy to clipboard operation
incubator-pagespeed-ngx copied to clipboard

RewriteLevel PassThrough still processing static files

Open 3urdoch opened this issue 6 years ago • 13 comments

I have an Nginx instance with the following in the main nginx.conf file which engages PassThrough mode and then just enables convert_meta_tags, inline_google_font_css, collapse_whitespace, remove_quotes.

    pagespeed unplugged;
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    pagespeed RewriteLevel PassThrough;
    pagespeed EnableFilters convert_meta_tags;
    pagespeed EnableFilters inline_google_font_css;
    pagespeed EnableFilters collapse_whitespace;
    pagespeed EnableFilters remove_quotes;

Then in a specific server, I have enabled this configuration with:

server {
  ...
  pagespeed on:
 ...
}

On version 1.9.10 this would, as expected only enable the selected filters. And would have no effect on any other resources like CSS or Javascript files. On version 1.13.35.2 I am now finding that my static resources are cached by pagespeed and changes are not reflected when the file is served by nginx. Each time a change is made, i need to flush the pagespeed cache to see the change reflected.

I have experimented by explicitly disabling all filters processing CSS with DisableFilters and ForbidFilters or setting no removing all the EnableFilters lines and just leaving RewriteLevel passthough; with no luck, Pagespeed still caches my CSS.

I can't see anything in the documentation that suggests the configuration has changed between 1.9 and 1.13 other than a change for pagespeed:off; to pagespeed:unplugged; which i have changed, other than that I would expect it to behave as it did before.

3urdoch avatar Jun 28 '18 08:06 3urdoch

It is 2020 but this issue still not fixed.

ru-dmitry avatar Feb 01 '20 17:02 ru-dmitry

as an experiment, can you see if disabling inline_google_font_css works around the problem?

jmarantz avatar Feb 02 '20 14:02 jmarantz

Thank you for your attention! Here is my config:

        pagespeed RewriteLevel PassThrough;
        pagespeed EnableFilters recompress_images;
        pagespeed EnableFilters in_place_optimize_for_browser;
        pagespeed ImagePreserveURLs On;
        pagespeed DisableFilters inline_google_font_css;

Adding last line did not help. ngx_pageseed gzipped and cached all js and css files.

ru-dmitry avatar Feb 02 '20 16:02 ru-dmitry

recompress_images will definitely cache & optimize image files, but that doesn't explain css/js. ImagePreserveURLs means it doesn't rewrite URLs but it will still optimize images in place, and to do that it must cache them -- pagespeed will serve origin content rather than blocking an HTTP response on a compute-intensive rewrite.

I'm not sure why CSS files are still being rewritten given your config. My guess is that there is an issue with the scope of your config, e.g. you have set up the above config on a vhost but pagespeed is associating your rewrite with a different vhost. E.g. you are serving your static assets from a different domain than the configuration.

This doc about inheriting vhost config may be helpful:

https://www.modpagespeed.com/doc/configuration#virtual-hosts

On Sun, Feb 2, 2020 at 11:25 AM Dmitry [email protected] wrote:

Thank you for your attention! Here is my config:

    pagespeed RewriteLevel PassThrough;
    pagespeed EnableFilters recompress_images;
    pagespeed EnableFilters in_place_optimize_for_browser;
    pagespeed ImagePreserveURLs On;
    pagespeed DisableFilters inline_google_font_css;

Adding last line did not help. ngx_pageseed gzipped and cached all js and css files.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-pagespeed-ngx/issues/1575?email_source=notifications&email_token=AAO2IPNVWXEPROZAX5FFCPDRA3XWFA5CNFSM4FHL5UT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKR2UZQ#issuecomment-581151334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO2IPN2SKWWYODCU2BHLSTRA3XWFANCNFSM4FHL5UTQ .

jmarantz avatar Feb 02 '20 16:02 jmarantz

@jmarantz Maybe is IPRO?

Lofesa avatar Feb 03 '20 13:02 Lofesa

The configuraiton he showed, if that's all there is, and is applied to his requests, should prevent IPRO for css and javascript. It will allow IPRO for images.

So my suspicion is that this is not the config that is being applied, due to vhost issues.

On Mon, Feb 3, 2020 at 8:32 AM Lofesa [email protected] wrote:

@jmarantz https://github.com/jmarantz Maybe is IPRO?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-pagespeed-ngx/issues/1575?email_source=notifications&email_token=AAO2IPJUUSZVKHMZVWJEYSDRBAMFZA5CNFSM4FHL5UT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKT3AIY#issuecomment-581414947, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO2IPOVA2VENC735HMC2TTRBAMFZANCNFSM4FHL5UTQ .

jmarantz avatar Feb 03 '20 13:02 jmarantz

This is the only pagespeed configuration and the only vhost on this server. There are no other rules.

ru-dmitry avatar Feb 03 '20 14:02 ru-dmitry

Well... nothing is lost by trying:

pagespeed InPlaceResourceOptimization off;

Lofesa avatar Feb 03 '20 15:02 Lofesa

Even so:

        pagespeed on;
        pagespeed FileCachePath /var/ngx_pagespeed_cache;
        pagespeed RewriteLevel PassThrough;

issue is present — just like stated in the opening post.

ru-dmitry avatar Feb 03 '20 18:02 ru-dmitry

And the specific issue you see is that you are modifying CSS or JS files and the changes are not seen by browsers, even after (say) shift-refresh?

On Mon, Feb 3, 2020 at 1:23 PM Dmitry [email protected] wrote:

Even so:

    pagespeed on;

    pagespeed FileCachePath /var/ngx_pagespeed_cache;

    pagespeed RewriteLevel PassThrough;

issue is present — just like stated in the opening post.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-pagespeed-ngx/issues/1575?email_source=notifications&email_token=AAO2IPJZI2G4ZJTHX6QV4H3RBBOJ5A5CNFSM4FHL5UT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKU3XMA#issuecomment-581548976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO2IPMVZN5MVYVP3NZXN5TRBBOJ5ANCNFSM4FHL5UTQ .

jmarantz avatar Feb 03 '20 18:02 jmarantz

Yes. And here are the headers (we can see that CSS is compressed by the module — tested on ngx-1.14.33.1-RC1):

cache-control: max-age=2592000
content-encoding: gzip
content-length: 1251
content-type: text/css
date: Sun, 18 Oct 2020 05:11:26 GMT
etag: W/"5c3de3db-fd0"
expires: Tue, 17 Nov 2020 05:11:26 GMT
server: nginx
status: 200
vary: Accept-Encoding
x-original-content-length: 4048

ru-dmitry avatar Oct 18 '20 05:10 ru-dmitry

I think something else in your serving path must be optimizing the CSS, because the etag you list above is not in the format used by mod_pagespeed. E.g. requesting https://www.modpagespeed.com/examples/images/Puzzle.jpg it responds with:

Etag: W/"PSA-aj-YsUBdV-i_6"

The lack of the "PSA-" prefix on your CSS file suggests this was optimized by something other than PageSpeed.

jmarantz avatar Oct 18 '20 13:10 jmarantz

There is "x-original-content-length" header that clearly means that the file has been processed by mod_pagespeed.

ru-dmitry avatar Oct 19 '20 04:10 ru-dmitry