Code Monkey home page Code Monkey logo

Comments (7)

dmtintner avatar dmtintner commented on July 18, 2024

I'd love to see this implemented as well. Currently is there any easy way to set certain pages not to cache?

I also think the default should be not to cache any wp-admin urls

from batcache.

Viper007Bond avatar Viper007Bond commented on July 18, 2024

Currently is there any easy way to set certain pages not to cache?

We use code like this:

if ( $_SERVER['HTTP_HOST'] == 'SomeSiteWeDontWantToCache.com' ) {
    $batcache['max_age'] = 0;
}

You could check for anything, including path or the existence of a specific cookie (which we also do).

I also think the default should be not to cache any wp-admin urls

Logged in users aren't served cached pages:

https://github.com/Automattic/batcache/blob/master/advanced-cache.php#L333-L341

from batcache.

spacedmonkey avatar spacedmonkey commented on July 18, 2024

Another good example

https://github.com/Automattic/vip-quickstart/blob/master/www/config/batcache-config.php#L58-L82

from batcache.

rohmann avatar rohmann commented on July 18, 2024

My method is a bit simpler. I'm using it on a few sites to allow the DONOTCACHEPAGE constant to abort caching. Just submitted a PR. Adding this would really help with plugin compatibility. More plugin developers seem to be using it to address issues discovered with W3TC and WP Super Cache.

from batcache.

vnsavage avatar vnsavage commented on July 18, 2024

This feature is a duplicate ( even tri-plicate? ) of functionality we already have. I'd add the batcache_cancel() function to the list as well.

from batcache.

rohmann avatar rohmann commented on July 18, 2024

@vnsavage and @Viper007Bond

I think you may be missing the point here. Yes, Batcache already supports ways to abort the cache, but these "features" you're referring to requires additional configuration on a per site basis.

The idea here was to just let Batcache natively support a popular constant to trigger the cancelation. Both W3TC and WP SuperCache check for DONOTCACHEPAGE, so many plugins like WooCommerce for example will simply look for that constant and abort the cache when needed.

If Batcache just supported it out of the box, there would be less per site configuration when setting up plugins that are already doing some caching conflict resolution out of the box based on DONOTCACHEPAGE

Please reconsider. Thanks!

from batcache.

otarhe avatar otarhe commented on July 18, 2024

Is there anyway we can exclude asset files like .js from Batcache?

I cant find a way to make the below snippet work.

https://github.com/Automattic/vip-quickstart/blob/master/www/config/batcache-config.php#L58-L82

if ( substr($_SERVER['REQUEST_URI'], -3) == '.js' ) {
$batcache['max_age'] = 0; // disable batcache
}

from batcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.