Ref: https://www.varnish-cache.org/docs/3.0/tutorial/esi.html http://www.w3.org/TR/esi-lang
In the template add something like:
<nocache callback="time" />And in batcache
- Before saving the HTML in the cache, do a strpos for <nocache , and save true/false in the cache too.
- If true, use the kses_hair function and generate an array of positions/callbacks, and store in cache too.
- When serving a cached page check for that bool. If false, serve as usual.
- If true, use the cached array to generate the blocks, inject and strip all the <nocache... tags.
<nocache> should only be allowed in the templates/plugins. It should be stripped from any user generated content (commments, post content, etc).
<nocache is_user_logged_in callback="time"> <?php time(); ?> </nocache>Set a nocache tag only for logged in users. Visitors won't execute the callback, and will get what's inise the nocache tag.
<nocache expiration='3600' callback="time" />Add a different expiration time for that fragment. ie: Twitter widget in a page that doesn't need to refresh too often.