Tag Archives: Easy Digital Downloads

Blog, Easy Digital Downloads, Moneybird

Easy Digital Downloads MoneyBord 1.0.7

In the latest release of Easy Digital Downloads MoneyBird, EDD MoneyBird in short, we have added several cool new features: Support for periods in MoneyBird If you use EDD recurring, the synchonised invoices will now have the corresponding periods added. Support for the EDD VAT EU: VAT number and VAT company will be synchronised as…

Continue reading

Blog

Exclude pages from caching based on post type

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' ) ) {

     add_filter('do_rocket_generate_caching_files','__return_false');

  }

}
×