How can I use Varnish Edge Side includes for a sidebar?

You can do something like the following: If you have a sidebar called “Sidebar” <?php if ( !dynamic_sidebar(“Sidebar”) ) : endif; ?> You wrap it in ESI tags, one for if ESI is not enabled and one if it is: <esi:remove> <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(“Sidebar”) ) : endif; ?> </esi:remove> <!–esi <esi:include src=”https://wordpress.stackexchange.com/wp-content/plugins/myplugin/esihandler.php”/> … Read more

Varnish + Nginx for WordPress is Good?

Yes, it is good, but other options are also good. There is no silver bullet in term of webservers and caching software, if there was everybody would have been using the same tools. It depends both on what are your actual needs and how comfortable are you with managing the tools. For example it might … Read more

WordPress on Nginx – Missing admin/toolbar

If you’re using Varnish and you’re not seeing the admin bar it’s because you probably have a rule in /etc/varnish/default.vcl that looks like this: sub vcl_recv { if (!(req.url ~ “wp-(login|admin)”)) { unset req.http.cookie; } } That’s going to keep the admin bar from showing up because you’re dropping cookie stuff from all pages except … Read more

Popular posts with Varnish ESI

But if the single post page is cached in Varnish, wouldn’t the count stay the same? Yes, if the whole page is cached then the PHP will never get run to update the view count. You’d need an ESI block to call an uncached URL that will increment the view count. Or even an Ajax … Read more

WordPress mobile version is not responsive anymore after installing varnish

It’ entirely possible that WordPress detects the device based on the User-Agent requests header and displays the right version of the website accordingly. If you don’t instruct Varnish to create a cache variation depending on the device, only one version will be cached per page. Device detection Varnish is able to perform device detection by … Read more

dynamic page not displaying correctly when Varnish hosting ignores query string parameters

Caching content with query string parameters Varnish hashes the URL and uses this value as its cache key. When a single value in the URL changes, the cache key changes. This would result in a cache miss. Query string parameters are exceptionally prone to this: omitting a parameter, adding a parameter, or changing the order … Read more

Why does WP HTTP API switch the method (POST/PURGE) to GET when redirecting (302)?

The change of method to GET after redirect from POST, PURGE, BAN whatever, is perfectly legal and been there, and will be without WordPress (it has nothing to do with it, really). Welcome to the World Wide Web: Note: For historical reasons, a user agent MAY change the request method from POST to GET for … Read more