To improve site speed for a website I often use WP Rocket: I think it’s one of the fastest caching plugins for WordPress. When a page is being cached, it’s actually saved in a separate folder as a html file. This way, the website doesn’t have to create the page from the php code: there’s a ready made file that can be served immediately. This is way faster then when the server needs to parse the entire code (of course this depends on your server speed as well).

In some cases it is not convenient to cache every page straight from the cache. For example, if you have a webshop with a sidebar with cart, where sometimes a product is in the cart, but sometimes it isn’t. You don’t want the product to be always in the cart, even if the user didn’t add it yet… This is what I encountered with an Easy Digital Downloads webshop.

Of course you can disable caching for those pages. That’s what I did first: I added the DONOTCACHE constant to the downloads template. But when you do that, you also lose the other features of WP Rocket, like the javascript minification etc. As a result, users who have visited the homepage first, have the minified js files in the cache, so the browser will then download the unminified js files. This is not optimal. I wanted to keep those features, without the page being cached.

To achieve this I’ve contact WP Rocket support, who were very helpful. In the end we created a solution where the page cache is not used for the post type ‘download’. In WooCommerce you could use post type ‘product’ to achieve the same thing.


  don't create page cache on downloads pages. 


add_action('wp', 'rsssl_wprocket_no_page_cache');

function rsssl_wprocket_no_page_cache(){
  global $post;

  if ($post && ( get_post_type($post)=='download' ) ) {




Leave a Reply

Your email address will not be published. Required fields are marked *