Not working depending on User-Agent?

28 views
Skip to first unread message

j...@aaptiv.com

unread,
Dec 21, 2017, 11:52:28 AM12/21/17
to ngx-pagespeed-discuss
Hi there,
I'm sorry if I'm missing a documented behavior, but I've been googling quite a bit and can't find any reference to this.

When I go to http://${my_url}/?PageSpeedFilters=+debug in Chrome, I do not see any debugging messages (or X-Page-Speed header) in the response.

When I run 
curl -H http://${my_url}/?PageSpeedFilters=+debug
I see the expected debugging messages in the HTML, as well as X-Page-Speed: 1.11.33.2-0 in the response headers.

When I run
curl -H "User-Agent: foo" http://${my_url}/?PageSpeedFilters=+debug
I do not see the debugging messages or header.

It seems to me to be pretty clear that having a User-Agent header somehow disables the plugin. Can someone please help me?

My nginx config:
server {

    pagespeed on;

    pagespeed RewriteLevel OptimizeForBandwidth;
    pagespeed EnableFilters combine_javascript,sprite_images,combine_css,inline_javascript;
    pagespeed Domain https://s3.amazonaws.com;
    pagespeed Domain https://ajax.googleapis.com;
    pagespeed Domain https://www.google-analytics.com;
    pagespeed Domain https://cdnjs.cloudflare.com;
    pagespeed Domain https://*.doubleclick.net;
    pagespeed Domain https://tr.snapchat.com;
    pagespeed Domain https://www.facebook.com;
    pagespeed Domain https://fonts.googleapis.com;

    pagespeed AvoidRenamingIntrospectiveJavascript off;

    # Needs to exist and be writable by nginx.  Use tmpfs for best performance.
    pagespeed FileCachePath /var/ngx_pagespeed_cache;

    listen       80  default_server;
    server_name  _;

    # Ensure requests for pagespeed optimized resources go to the pagespeed handler
    # and no extraneous headers get set.
    location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
      add_header "" "";
    }
    location ~ "^/pagespeed_static/" { }
    location ~ "^/ngx_pagespeed_beacon$" { }

    location /ngx_pagespeed_statistics { allow all;}
    location /ngx_pagespeed_global_statistics { allow all; }
    location /ngx_pagespeed_message { allow all; }
    location /pagespeed_console { allow all; }
    location ~ ^/pagespeed_admin { allow all; }
    location ~ ^/pagespeed_global_admin { allow all; }

    pagespeed StatisticsPath /ngx_pagespeed_statistics;
    pagespeed MessagesPath /ngx_pagespeed_message;
    pagespeed ConsolePath /pagespeed_console;
    pagespeed AdminPath /pagespeed_admin;


    location / {
        proxy_pass       http://UPSTREAM_SERVER;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header Host               $http_host;
        proxy_set_header X-Forwarded-Host   $host;
        proxy_set_header X-Forwarded-Server $host;
    }

}

nginx_pagespeed_version: 1.11.33.2
nginx_version: 1.10.1

Thank you!

Longinos

unread,
Dec 21, 2017, 3:19:42 PM12/21/17
to ngx-pagespeed-discuss
Hi
1st of all, you don´t need all those pagespeed Domain, only domains where pagespeed module is running.

Perhaps the issue is between the origin and the proxy.

I think you need to rewrite UPSTEAM_SERVER url´s to {my_domain} url´s
pagespeed MapOriginDomain origin_to_fetch_from origin_specified_in_html [host_header];

j...@aaptiv.com

unread,
Dec 22, 2017, 12:03:17 PM12/22/17
to ngx-pagespeed-discuss
Thank you for these suggestions, I can look into them, but I still don't understand why the behavior would be different depending on the User-Agent. Do you have any insight into that?

Longinos

unread,
Dec 23, 2017, 5:45:29 AM12/23/17
to ngx-pagespeed-discuss
Some optimizations are done for user-agent basis.

My bet is some problem between proxy and origin servers.
What you see on the origin servers logs?

In other hand I cannot see any config to enable proxy cache (proxy_cache zone, proxy_cache_background_update on,proxy_cache_methods GET | HEAD | POST, and so on). w/o proxy cache all the request are send to the origin, try to serve request fom proxy and see if some thing changes.

Include
UPSTREAM_SERVER domain in the pagespeed domain directive
Reply all
Reply to author
Forward
0 new messages