--
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/CAL_utwZLanHtHjVwPbfXkin4GF2TbM0V10hvOsfofAwi8DPC8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAEnJKPH2%2BJ3RVdjuv811SrZzkmrkn_KUwc9UWwpztL%3DxaYeCEA%40mail.gmail.com.
sub vcl_recv() {
if(req.request = "PURGE"){set req.request = "GET";set req.hash_always_miss = true;}
}
sub vcl_recv() {
if(req.request = "PURGE"){set req.request = "GET";
unset X-PSA-Purge-Request;set req.hash_always_miss = true;}}
sub vcl_recv() {
if(req.request = "PURGE"){set req.request = "GET";
unset X-PSA-Purge-Request;set req.http.User-Agent = "fake user agent";set req.hash_always_miss = true;}}
14 RxRequest c PURGE14 RxURL c //mens/denim.html14 RxProtocol c HTTP/1.114 RxHeader c Host: redacted.host.tld14 RxHeader c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.814 RxHeader c Pragma: no-cache14 RxHeader c DNT: 114 RxHeader c Referer: http://redacted.host.tld/14 RxHeader c Accept-Language: en-US,en;q=0.8,de;q=0.6,fr;q=0.414 RxHeader c PS-CapabilityList: ll,ii,dj:14 RxHeader c X-Device: desktop14 RxHeader c X-Varnish: 71787949314 RxHeader c Accept-Encoding: gzip14 RxHeader c X-PSA-Purge-Request: 114 RxHeader c User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 mod_pagespeed/1.6.29.7-3566
# We remove 'double-slashes' from the requested URL, it causes bugs with varnishif(req.url ~ "^(.*)//(.*)$"){set req.url = regsub(req.url,"^(.*)//(.*)$","\1/\2");}
Hi Jud,
So here are some of my findings. TL;DR: I got it to work, but there are a few gotchas and a small bug (my last paragraph).In the past I had tried to ModPagespeedDownstreamCachePurgeMethod MYOWNHTTPVERB
This doesn't seem to be valid: mod_pagespeed never sends anything to varnish. I couldn't find any error message in my apache logs.Not sure if PURGE and GET are the only verbs allowed, or, if any verb defined in the RFC are valid.
---------------
I then tried ModPagespeedDownstreamCachePurgeMethod PURGEwith the VCL we talked about earlier:sub vcl_recv() {if(req.request = "PURGE"){set req.request = "GET";set req.hash_always_miss = true;}
}This time the PURGE request is received by varnish.Varnish then correctly send a GET request to the URL, but, the page received and put in cache is not optimized.By inspecting the request made by mod_pagespeed, I realized that it includes a header "X-PSA-Purge-Request: 1", which I assumed is used by mod_pagespeed to know the request is coming from itself.
---------------I then tried this VCL:sub vcl_recv() {if(req.request = "PURGE"){set req.request = "GET";unset X-PSA-Purge-Request;set req.hash_always_miss = true;}}
This still didn't work. The PURGE request is received by Varnish. Varnish makes a GET request to the URL, but the response is not optimized.
By inspecting the HTTP request again I noticed that mod_pagespeed also adds it's user-agent to the user-agent string: mod_pagespeed/1.6.29.7-3566 in my case.---------------I then tried this VCL:sub vcl_recv() {if(req.request = "PURGE"){set req.request = "GET";unset X-PSA-Purge-Request;set req.http.User-Agent = "fake user agent";set req.hash_always_miss = true;}}It works!The PURGE request is sent to Varnish, which in turn send a GET request to mod_pagespeed, which in turn sends the optimized version of the page.I'm however unclear about the potential side effects of removing mod_pagespeed user-agent string and X-PSA-Purge-Request header.
---------------While debugging I noticed a small bug:The PURGE request sent by mod_pagespeed has a double slash in it:14 RxRequest c PURGE14 RxURL c //mens/denim.html14 RxProtocol c HTTP/1.114 RxHeader c Host: redacted.host.tld14 RxHeader c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.814 RxHeader c Pragma: no-cache14 RxHeader c DNT: 114 RxHeader c Referer: http://redacted.host.tld/14 RxHeader c Accept-Language: en-US,en;q=0.8,de;q=0.6,fr;q=0.414 RxHeader c PS-CapabilityList: ll,ii,dj:14 RxHeader c X-Device: desktop14 RxHeader c X-Varnish: 71787949314 RxHeader c Accept-Encoding: gzip14 RxHeader c X-PSA-Purge-Request: 114 RxHeader c User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 mod_pagespeed/1.6.29.7-3566It so happens that my VCL remove double slashes for some specific reason about my website, so the double slash doesn't affect me. However, I believe mod_pagespeed shouldn't be sending purge requests with a double slash.Here's the code I use in my VCL to remove the double slash:# We remove 'double-slashes' from the requested URL, it causes bugs with varnishif(req.url ~ "^(.*)//(.*)$"){set req.url = regsub(req.url,"^(.*)//(.*)$","\1/\2");}I'll file a bug for this.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAL_utwbom-JQGBuSZyH-o9awxSXRhCTku_Se2mNnXZMZiL62%2BQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAKpPfmMkdiMXw4s%2B-DxWJnWzsyyKdqeY0ZYr56N-_fg-OOE9-g%40mail.gmail.com.
Hi Anupama,Thank you for your answer.
- Changing the User-Agent to "fake user-agent" is indeed a bad idea, it was more a quick hypothesis test than a real solution. What I did in the end is just replace mod_pagespeed by something else, leaving the original User-Agent string alone.i.e. Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 mod_pagespeed/1.6.29.7-3566 gets transformed into Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 mod_pagefast/1.6.29.7-3566if(req.request ~ "PURGE"){set req.request = "GET";set req.http.User-Agent = regsuball(req.http.User-Agent,"mod_pagespeed","mod_pagefast");set req.hash_always_miss = true;}- I also removed the config that was stripping the X-PSA-Purge-Request and the optimization still happens so that's good for me.- removing the trailing slash from ModPagespeedDownstreamCachePurgeLocationPrefix fixes the double slashAll in all, this setup currently runs on my development server with no issues, this sounds promising.
On a related note:I don't know the internals of mod_pagespeed and thus I'm unclear as to why if I don't replace "mod_pagepeed" to "mod_pagefast" in the User-Agent string, mod_pagespeed won't send me an optimized page. Could you enlighten me (without necessarily entering into too much details)?
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAL_utwbKmfkMM3wMYVnVwiioLQhTRWhBzhOB862h9ogzBuObFA%40mail.gmail.com.
On Tue, Apr 1, 2014 at 11:00 PM, Hugues Alary <hug...@betabrand.com> wrote:
Hi Anupama,Thank you for your answer.
- Changing the User-Agent to "fake user-agent" is indeed a bad idea, it was more a quick hypothesis test than a real solution. What I did in the end is just replace mod_pagespeed by something else, leaving the original User-Agent string alone.i.e. Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 mod_pagespeed/1.6.29.7-3566 gets transformed into Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 mod_pagefast/1.6.29.7-3566if(req.request ~ "PURGE"){set req.request = "GET";set req.http.User-Agent = regsuball(req.http.User-Agent,"mod_pagespeed","mod_pagefast");set req.hash_always_miss = true;}- I also removed the config that was stripping the X-PSA-Purge-Request and the optimization still happens so that's good for me.- removing the trailing slash from ModPagespeedDownstreamCachePurgeLocationPrefix fixes the double slashAll in all, this setup currently runs on my development server with no issues, this sounds promising.I am glad your configuration works!On a related note:I don't know the internals of mod_pagespeed and thus I'm unclear as to why if I don't replace "mod_pagepeed" to "mod_pagefast" in the User-Agent string, mod_pagespeed won't send me an optimized page. Could you enlighten me (without necessarily entering into too much details)?I don't know why this would be the case either. Adding a few folks who might know what is going on here.
--
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/CA%2B_-ou_WgjeKewdAmCHMFNTOfciCu3spUo1-MCKYY1vDn0RLtA%40mail.gmail.com.