plone/plone.app.caching — pull request #2 by dokai (2012-11-01 11:28:52+00:00)
Title: Fixed purge paths for virtual hosting scenarios using virtual path components.

...nents.

In case the virtual host setup includes virtual path components which are not
part of the ZODB path hierarchy, the generated purge paths are incorrect.

For example, assuming the following rewrite rule in Apache

RewriteRule ^/a/b/?(.*)/?$ http://127.0.0.1:5128/VirtualHostBase/http/%{SERVER_NAME}:80/VirtualHostRoot/_vh_a/_vh_b/$1 [P,L]

which contains a two-part virtual path ``/a/b`` results in the following kind of
of URL to be sent to Varnish

/VirtualHostBase/http/server.com:80/VirtualHostRoot/_vh_a/_vh_b/plone/my-document

however, when the purge URLs are generated using the ``absolute_url_path``
method they look like

/VirtualHostBase/http/server.com:80/VirtualHostRoot/_vh_a/_vh_b/a/b/plone/my-document

containing the virtual "/a/b" part which does not match with what gets cached in
Varnish.

Instead of using ``absolute_url_path`` the ``virtual_url_path`` method should be
used instead to avoid the virtual parts.

Note that ``virtual_url_path`` does not have a leading slash which needs to be
added explicitly.