• Resolved Sa?a

    (@stodorovic)


    Many caching plugins use the constant DONOTCACHEPAGE to prevent caching of current URL. It’ll improve compatibility with some plugins (including WooCommerce even it is already excluded by server rules).

    I’m testing following code and it works:

    add_action( 'template_redirect', array( $this, 'donotcachepage' ), 9999 );

    public function donotcachepage() {
    	if ( headers_sent() || ! defined( 'DONOTCACHEPAGE' ) ) {
    		return;
    	}
    
    	header( 'X-Cache-Enabled: False', true );
    }
    

    It’ll be nice to you add this feature request in next release.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Sa?a

    (@stodorovic)

    I just found https://www.ads-software.com/support/topic/add-support-for-donotcachepage-or-add-a-filter-to-exclude-pages/

    The code isn’t perfect because it’s possible that some plugins define the constant when the page is partially rendered, but it isn’t always case (and some plugins doesn’t support it). Eg. WooCommerce uses the wp action to set this constant. I’m also writing some custom code which will define the constant before template_redirect action (when caching plugins often create output buffer).

    Anyway, I can send header X-Cache-Enabled: False if this FR isn’t acceptable.

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    This is not something we will support anytime soon if ever as mentioned in the other topic. You can use a BYPASS cookie if you want to exclude such pages from being cached dynamically or you can use the exclude function in the plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude URL with the constant DONOTCACHEPAGE’ is closed to new replies.