Dynamic Page Display Behind a Proxy Cache
Proxy caches like Varnish can help Drupal to perform and scale much better in certain situations. However, it can also limit your ability to interact with anonymous users. When using a proxy cache, it is still possible to serve dynamic pages to your anonymous users. Understanding the way that a proxy cache works is the first step to being able to use it effectively. Simply placing Varnish in front of a Drupal site will not necessarily fix everything.
Cookies are the only way to really store information about anonymous users but proxy caching generally doesn't serve cached pages when cookies are set. The first step then is ensuring that your proxy cache will ignore any cookies you set. Failure to do this will break your caching strategy. The second step is to create javascript that can parse the cookies you set. This javascript will be served with your cached page and see the cookies you have set.
This javascript can be used to parse which cookies are set and then set a cookie that will route the user past the cache. This cookie can then be immediately unset so that the anonymous user will get a cached page on their next request. By only showing one un-cached page to the user you can maintain a caching strategy while still showing some dynamic content to anonymous users.



Comments
Post new comment