[Setup] Doubt about plone - caching (varnish)

11 views
Skip to first unread message

Armando Andrade

unread,
Feb 16, 2012, 11:08:17 AM2/16/12
to plone...@lists.plone.org
Regards.

We have deployed three servers with the configuration showed in diagram, basically, we have an arrange of nginx -> varnish -> haproxy -> (4 instances of plone) (varnish cache 1 and 2)  in two servers, and an arrange of nginx -> haproxy -> (4 instances of plone) for edition purposes in another. Now two questions here:

a) When I edit one news item, how can plone tell to varnish cache 1 and 2 in the other group of instances servers that, there was a change and they have to invalidate that object, if the change was made in the edition server?.

b) if I change a newsitem that affects my portal page, plone sends the invalidation for the newsitem, and  it sends the invalidation for the portal page affected as well?

Gil Forcada

unread,
Feb 17, 2012, 4:54:56 PM2/17/12
to Armando Andrade, plone...@lists.plone.org
El dj 16 de 02 de 2012 a les 10:08 -0600, en/na Armando Andrade va
escriure:

> Regards.
>
> We have deployed three servers with the configuration showed in
> diagram, basically, we have an arrange of nginx -> varnish -> haproxy
> -> (4 instances of plone) (varnish cache 1 and 2) in two servers, and
> an arrange of nginx -> haproxy -> (4 instances of plone) for edition
> purposes in another. Now two questions here:
>
> a) When I edit one news item, how can plone tell to varnish cache 1
> and 2 in the other group of instances servers that, there was a change
> and they have to invalidate that object, if the change was made in the
> edition server?.

Hi,

If you use plone.app.caching you can configure which servers (varnish or
others) have to be pinged with the PURGE method so that they invalidate
the pages cached for that specific object.

> b) if I change a newsitem that affects my portal page, plone sends the
> invalidation for the newsitem, and it sends the invalidation for the
> portal page affected as well?

Hopefully someone else will reply on that.

Cheers,

> _______________________________________________
> Setup mailing list
> Se...@lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-setup


--
Gil Forcada

[ca] guifi.net - una xarxa lliure que no para de créixer
[en] guifi.net - a non-stopping free network
bloc: http://gil.badall.net
planet: http://planet.guifi.net

_______________________________________________
Setup mailing list
Se...@lists.plone.org
https://lists.plone.org/mailman/listinfo/plone-setup

Nathan Van Gheem

unread,
Feb 17, 2012, 5:00:37 PM2/17/12
to Gil Forcada, plone...@lists.plone.org, Armando Andrade
b) if I change a newsitem that affects my portal page, plone sends the invalidation for the newsitem, and  it sends the invalidation for the portal page affected as well?
No, it'll only invalidate that one page and normal ttls will take place for the portal page.

We've implemented our own manual purge method to address situations like this.

Mikko Ohtamaa

unread,
Feb 17, 2012, 7:55:49 PM2/17/12
to plone...@lists.plone.org
On Sat, Feb 18, 2012 at 00:00, Nathan Van Gheem <vang...@gmail.com> wrote:
b) if I change a newsitem that affects my portal page, plone sends the invalidation for the newsitem, and  it sends the invalidation for the portal page affected as well?
No, it'll only invalidate that one page and normal ttls will take place for the portal page.

We've implemented our own manual purge method to address situations like this.


URL based purge is good only when you know the URLs to purge and the content is not embedded in the listings (like news portlet). Purge works well for images and files which have fixed urls and don't have payload embedded in HTML. If the site is complex it's very hard to set rules how to purge the listing pages where the content item appears... I am not sure could this be done with etags and stuff? Plone internally does not know it. I think there was a trick involving the last catalog modification date, but I don't know how to execute it.

If  it's not too expensive you can simply purge the whole Varnish at once on every Plone edit:

http://opensourcehacker.com/2011/09/08/purge-varnish-cache-from-python-web-application/

Suitable for low edit volume sites.

-Mikko
 



--
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

Laurence Rowe

unread,
Feb 18, 2012, 11:51:05 AM2/18/12
to se...@lists.plone.org

Mikko Ohtamaa wrote

>
> On Sat, Feb 18, 2012 at 00:00, Nathan Van Gheem &lt;vangheem@&gt; wrote:
>
>> b) if I change a newsitem that affects my portal page, plone sends the
>>> invalidation for the newsitem, and it sends the invalidation for the
>>> portal page affected as well?
>>>
>> No, it'll only invalidate that one page and normal ttls will take place
>> for the portal page.
>>
>> We've implemented our own manual purge method to address situations like
>> this.
>
>
>
> URL based purge is good only when you know the URLs to purge and the
> content is not embedded in the listings (like news portlet). Purge works
> well for images and files which have fixed urls and don't have payload
> embedded in HTML. If the site is complex it's very hard to set rules how
> to
> purge the listing pages where the content item appears... I am not sure
> could this be done with etags and stuff? Plone internally does not know
> it.
> I think there was a trick involving the last catalog modification date,
> but
> I don't know how to execute it.
>

I tried to come up with a generic solution involving headers
(http://svn.plone.org/svn/collective/experimental.depends/trunk/README.txt)
but I think it's pretty much impossible as there is no easy way to know
where a link to a page might turn up (in a navigation tree or listing).

I do think adding headers with the portal type and any portlets could be
useful - this would allow you to write Varnish VCL that bans pages which are
a Collection or contain a Collection portlet.

> If it's not too expensive you can simply purge the whole Varnish at once
> on every Plone edit:
>
> http://opensourcehacker.com/2011/09/08/purge-varnish-cache-from-python-web-application/
>
> Suitable for low edit volume sites.
>

For these types of sites, I configure Varnish to ban all pages with a
Content-Type of text/html in addition to the subject of the PURGE request
itself:

if (req.request == "PURGE") {
if (req.http.X-Real-IP != "127.0.0.1") {
error 405 "Not allowed.";
}
purge("obj.http.host == " req.http.host " && obj.url == " req.url);
purge("obj.http.Content-Type ~ ^text/html");
error 200 "Purged";
}

Laurence


--
View this message in context: http://plone.293351.n2.nabble.com/Doubt-about-plone-caching-varnish-tp7291445p7297254.html
Sent from the Installation, Setup, Upgrades mailing list archive at Nabble.com.

Reply all
Reply to author
Forward
0 new messages