Purging both pagespeed cache and downstream cache after a change

61 views
Skip to first unread message

Lahcen Bensaad

unread,
Apr 23, 2015, 10:56:07 AM4/23/15
to ngx-pagesp...@googlegroups.com
I am using nginx + pagespeed + proxy_cache for a wordpress site.
I changed Cache-Control to public, max-age=3600 for html generated by pagespeed so that proxy_cache can cache it.
I want wordpress to purge both  pagespeed and proxy_cache caches when there is a new post for example.
I used the plugin neginx helper for wordpress but it did not work, i think because pagespeed uses the User-Agent in the cache key so and plugin does not know about them. I tried to purge pagespeed by visiting the url: "http://example.com/pagespeed_admin/cache?purge=/" and the purge was successful but it did not propagate the purge down to proxy_cache, although i have already set: 
pagespeed DownstreamCachePurgeLocationPrefix http://example.com:80/;

But i think that that setting is meant only for purging when there is a new optimization rewriting. Is this correct?

What is the exact solution for this problem, I mean purging both caches when there is a change?

 

Jeff Kaufman

unread,
Apr 23, 2015, 11:31:40 AM4/23/15
to ngx-pagesp...@googlegroups.com
PageSpeed doesn't cache your html; the downstream cache does this.
That means you only need to PURGE from the downstream cache.

What makes this tricky is that with the current downstream cache
configuration there is user-agent based fragmentation. You would need
to send it a purge request for each of the UA-fragments configured.

We're planning to stop recommending UA-fragmentation:
http://www.jefftk.com/downstream-caching-draft Once there's no
fragmentation you would only need to send a single PURGE to the
downstream cache.

The DownstreamCachePurgeLocationPrefix command is just so PageSpeed
can send PURGEs after completing a background rewrite.
> --
> You received this message because you are subscribed to the Google Groups
> "ngx-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ngx-pagespeed-di...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
> For more options, visit https://groups.google.com/d/optout.

Lahcen Bensaad

unread,
Apr 23, 2015, 12:14:05 PM4/23/15
to ngx-pagesp...@googlegroups.com
Thank you Jeff
So how to purge each of the UA-fragments?

Lahcen Bensaad

unread,
Apr 23, 2015, 12:42:07 PM4/23/15
to ngx-pagesp...@googlegroups.com
Jeff, is it possible to disable the UA cache fragmentation in current version of pagespeed?


On Thursday, April 23, 2015 at 4:31:40 PM UTC+1, Jeff Kaufman wrote:

Jeff Kaufman

unread,
Apr 23, 2015, 12:45:49 PM4/23/15
to ngx-pagesp...@googlegroups.com
On Thu, Apr 23, 2015 at 12:42 PM, Lahcen Bensaad
<lahcen...@gmail.com> wrote:
> Jeff, is it possible to disable the UA cache fragmentation in current
> version of pagespeed?
>

Yes. The draft setup in
http://www.jefftk.com/downstream-caching-draft will work with the
current version of pagespeed. It's an alternate recommended
configuration.

>
> how to purge each of the UA-fragments?

Send multiple PURGE requests, each with a different User-Agent header.
One for each of the cache fragments:

User-Agent: Chrome/100
User-Agent: Firefox/100
User-Agent: iPhone
User-Agent: bot
User-Agent: default
Message has been deleted

Lahcen Bensaad

unread,
Apr 23, 2015, 3:04:17 PM4/23/15
to ngx-pagesp...@googlegroups.com
Many thanks Jeff
But why you are going to stop UA-Fragments?

Jeff Kaufman

unread,
Apr 23, 2015, 3:15:05 PM4/23/15
to ngx-pagesp...@googlegroups.com
We like UA fragmentation because it means PageSpeed can optimize more
thoroughly, but there are several big downsides:

* it requires keeping complicated regexps in sync with C++ code
* what fragments to divide UAs into changes over time, and as browser
share changes we'd need to keep updating it
* it makes purging hard (your issue)
* it makes setup hard, decreasing the number of people who set up
downstream caching
* it increases the required cache size
> --
> You received this message because you are subscribed to the Google Groups
> "ngx-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ngx-pagespeed-di...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages