Code Monkey home page Code Monkey logo

batcache's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

batcache's Issues

Set Memcached Server Host

Where in batcache, do I define the memcached server? Ours is not on localhost. I looked all through the file advanced-cache.php and didn't see it defined anywhere.

serve stale content if necessary

This would probably require a massive refactoring of batcache, but it would be very cool if it could serve stale content in the case that the site is experiencing problems. (e.g. database connection problems)

I believe this would require either adding a grace period to the cache expiration, or doing away with cache expiration entirely. And then storing the real expiration timestamp alongside the cached response. When generating any fresh response you could (hopefully) look for any error status codes, and if there is an error try to use a previously cached version of that page.

Composer support

Composer is a popular php dependancy manger. Many of automattic plugins already support it, such as jetpack and babble. Supporting it is simple, only requires having a composer.json file in the root of the project and for the repo not using git submodules.

It is extremely useful if you want to load plugins from github 👍

Related #50 #44

Cache flush rules

First off - fantastic plugin. Thanks for making this available!

Secondly, it seems like batcache employs only very simple cache clearing functionality out of the box. What would you recommend in order to implement more granular cache flushing like one might find in W3TC? Would you recommend just creating our own simple admin UI to flush the full cache or individual pages, or is there a tool already in place to do these types of things? Thanks!

Undefined property batcache::$genlock

Notice: Undefined property: batcache::$genlock in /base/data/home/apps/s~continuous-wordpress-cms/test-permalink-1.377309360575349926/wordpress/wp-content/advanced-cache.php on line 510

Sometimes it appears reading the posts.

I think that the solution should be simply a declaration of the property at the beginning of the class setting it to "false" or with an empty value.

Deleted post fails to flush cache

When a post is deleted, clean_post_cache is fired after the post is deleted, this causes the Batcache function batcache_post to throw a Notice (as the post doesn't exist) and also fails to clean the cache URL (as the permalink can not be retrieved). My proposed solution would be to hook batcache_post into delete_post so it can be run before the post is deleted.

Version Number

The optional plugin have on the svn, wp repo the version number 1.2.
is the development on github actual or it is different? The master branch is currently newer from the commit updates, but what is the status of the wp repo?

Thanks for feedback.

Breaking the cache? Any function, callback filter etc.

I need to find a way to break the cache for a user systematically within either a javascript or php function. We are trying to provide an ad lite experience for subscribed users. The problem is when after they login to Piano (not wordpress), the cached page, with the ads, remains, at least until the cache naturally breaks. This has been extremely frustrating. This seems to be especially a problem on mobile devices.

Any help to figure this out would be very appreciated.

Cleaning up my logs....

can you add the following to the Batcache class?

var $do;
var $genlock;

I have verbose error_reporting running on eMusic and we get a ton of lines of Batcache notices in the logs - would be sweet as pie if we could get those out of there.

Thanks,
Scott Taylor

Last-Modified header's value isn't a valid date

Hi,

I'm trying to get around this problem for one my client but unable to find any solution. Here is server header:

curl -I https://saibabaguide.com
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 10 Jun 2012 21:06:02 GMT
Content-Type: text/html
Connection: keep-alive
X-Whom: l2-com-saiba
Vary: Cookie
Last-Modified: Sun, 10 Jun 2012 20:58:34 +0000
Cache-Control: max-age=152, must-revalidate
Front-End-Https: on

The "Last-Modified: Sun, 10 Jun 2012 20:58:34 +0000" should be "Last-Modified: Sun, 10 Jun 2012 20:58:34 GMT". Is there any setting to change this? In my php.ini, i got the following line:
date.timezone=America/Chicago

How do I change +0000 to GMT.

Thanks!
!

Exempt PUT, PURGE, and DELETE requests

By default, PUT requests aren't exempted from Batcache. This causes... issues with WP-API/JSON, especially when using Basic auth, as there's no cookie to override and cause a bypass. Suggest we bypass for PUT, PURGE, and DELETE requests.

Insert at advanced-cache.php line 229:

// Never batcache on PUT request.
 if ('PUT' === $_SERVER['REQUEST_METHOD'] || 'PURGE' === $_SERVER['REQUEST_METHOD'] || 'DELETE' === $_SERVER['REQUEST_METHOD']) {
    return;
 }

I'll put an actual PR in for this too.

Props to @allan23 for working this up.

_version key never gets set correctly if /wp-admin/ lives at another domain

The only place that the _version key gets set is in the batcache manager plugin. It uses get_permalink() to determine the URL. This is a problem if /wp-admin/ is accessed through a different domain than the main site. For us it sets the key using cms.site.com, but batcache looks it up using site.com, so it misses every time. I am not sure how to best fix this, but we have a nasty str_replace hacked in for now.

can advanced-cache.php be somewhere else?

Mainly so it doesn't delete any WP SUPER CACHE files which has the same name in the same place. I know you wouldn't use both but for testing purposes would be good to be able to switch between the 2.

Page version # can get out of sync with Batcache version # in a nasty way

Say I have 180 seconds as the default expiry on Memcached.

Bob creates a blog post at 12:00:00 AM. This increments Batcache's internal cache key that represents the most up-to-date version in the database. Let's call this url_key. The url_key version gets bumped to 1. url_key will expire in 180 seconds in Memcached, at 12:03:00 AM.

Lisa visits Bob's site at 12:00:30 AM. Batcache doesn't have a copy of this page, so it caches the page. Batcache's internal cache key that represents the version that the cached version of the page is at (let's call this the page cache key) gets set to whatever the url_key is at, so it gets set to 1. The page cache key gets set to expire at 12:04:00 (the default 180 seconds plus an extra 30 seconds that Batcache specifies).

At 12:02:00 AM, Bob realizes he made a spelling error, and updates his post. The url_key version gets bumped to 2, but since the cache key already exists in Memcached, the expiration will still happen at 12:03:00.

No one visits Bob's site until Joey does at 12:03:05. The url_key's expiration time has come, so it gets reset to 0. However, the page cache key is still at 1, as it doesn't expire until 12:04:00, so Batcache will not recache the page until that time comes, so Bob's copy fix won't be seen until then.

missing object_cache result in some warnings

Hi, in my vip dev environment I got these after activating batcache following the istructions:

Warning: include_once(/srv/wp-content/object-cache.php): failed to open stream: No such file or directory in /srv/wp-content/mu-plugins/batcache/advanced-cache.php on line 355

Warning: include_once(): Failed opening '/srv/wp-content/object-cache.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /srv/wp-content/mu-plugins/batcache/advanced-cache.php on line 355

reading advanched-cache.php seems like the absence of object-cache.php triggers a return at the half of the file...
why don't check if file exists before including, to avoid warning?
and why object cache is required for a large portion of the script, but it's not included in the plugin itself?
where can i find and download a stable version of it?

Improve batcache manager

So currently I have a PR #61 to add some improvements to cache clearing in batcache manger. But as I want to use batcache to cache for a much longer time than 5 minutes, I wanted to be sure that caches are clearing. To that end I wrote this https://github.com/spacedmonkey/batcache-manager . It builds on work of @skeltoac but clears out a lot more different kind of urls. I am still working on this, but I was wondering if people were interested in project. Should it be part of batcache? Is there anything else it could clear at the same time?

Related #62

Warning for call_user_func_array()

I'm getting this warning for call_user_func_array() in plugins.php when batcache is installed:

PHP Warning:  call_user_func_array() expects parameter 1 to be a valid callback, first
array member is not a valid class name or object in wordpress/wp-includes/plugin.php
on line 173

I patched my batcache.php as described in #21.

Anyone know if this is a bug or a problem in my configuration?

Exclude pages with DONOTCACHEPAGE

W3 Total Cache implements a DONOTCACHEPAGE constant and doesn't cache pages where this constant is set. WooCommerce and other plugins have adopted this principle.

I can't do a pull request as my fork differs too much, however here's a snippet of how I implemented DONOTCACHEPAGE in Batcache

if ( defined( 'DONOTCACHEPAGE' ) ) { if ( $batcache->debug_header ) { header("X-batcache: Caching cancelled - DONOTCACHEPAGE defined"); } return; }

Also uses @xyu's debug_header options

Undefined property batcache::$query

Notice: Undefined property: batcache::$query in /base/data/home/apps/s~continuous-wordpress-cms/test-permalink-1.377309360575349926/wordpress/wp-content/advanced-cache.php on line 388

Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /base/data/home/apps/s~continuous-wordpress-cms/test-permalink-1.377309360575349926/wordpress/wp-includes/plugin.php on line 192

It seems that a simple if statement to assign the property should solve the issue.

Batcache not working with WPML

Hi!
I have 2 WordPress sites on the same server with Batcache and APC Object Cache Backend plugin installed. Unique WP_APC_KEY_SALT defined on each wordpress site.

All plugins & WordPress core are up-to-date.
Debug option turned on both sites.
No error has been logged in Nginx & php error logs.

When I check the debug message: -
travellersquestion.com ( without WPML ) works perfectly, Batcache message is shown;
tangrufus.com ( with WPML ) shows no trace about Batcache

If WPML is deactivated, Batcache works on tangrufus.com.

Any suggestions to make Batcache works with WPML?

Thanks!

set $seconds = 0 in the batcache class and could not find 'served from batcache in xxx seconds'

var $times   =    2; // Only batcache a page after it is accessed this many times... (two or more)
var $seconds =  0; // ...in this many seconds (zero to ignore this and use batcache immediately)

Hi, after I set $seconds = 0; I alwasy get the following comments:

generated in 0.243 seconds
64311 bytes batcached for 7200 seconds

And Never see the ‘served from batcache’ comment. Is it right? Thanks.

generated 10 seconds ago
generated in 0.124 seconds
served from batcache in 0.001 seconds
expires in 7190 seconds

Bad cookie default configuration disabling cache when not needed

there are common cookies that will disable batcache because there is bad default cookie configuration. Currently, all cookies that begin with wp will cause cache to bypass. But there are no wp cookies I am aware of that should disable cache. But there are cookies like wp_lang or wpl_* from wpeka gdpr plugin, that will cause batcache to not cache the page. I run into this issue in Pressable hosting sertvice, where they are using batcache for their distributed Edge Cache implementation, but there is no way to change configuration of it

I made pull request with my proposed changes in default behavior

#105

Uninstall Instructions

There does not seem to be absolutely any instructions whatsoever across the entire internet that outline how to uninstall / delete Batcache.

I figured it would be obvious:

  • Delete the batcache.php plugin file
  • Delete the advanced_caceh.php file
  • Remove all instances of the WP_CACHE variable in the wp-config.php file

Did all of this, and the files on my client's WordPress installation are still caching and it is absolutely impossible to develop with this on.

If anyone could please advise as to a way to disable this ridiculously pervasive plugin, I would greatly appreciate it.

Thanks!

No clear all method

Currently there is no way to clear all urls stored in batcache. The batcache manager only seems to clear post page on update. However if there is a site wide change, such as changing theme, installing plugin or editting the customizer, all urls should be flushed.

I think there is a way we could do this, without keeping track of all urls in cache. We could do something similar to advanced-post-cache. In the bit code, when you send a flush, it changes the group. This effectively changes the salts the cache key and forces caches to regenerate.

I was going to start work on this, but I thought it would be better to get people' thoughts first.

'configure_groups' being called too late?

Hi, I'm just wondering why you have this line:

$batcache->configure_groups();

after this line:

$batcache->url_version = (int) wp_cache_get("{$batcache->url_key}_version", $batcache->group);

What if the cache key depends on 'batcache' existing in the set of global groups. Wouldn't it make more sense to switch the two lines?

Provide an example on how to override default configuration

I think an example on how to use a custom configuration would be really helpful for people who don't like reading the code to know how to do that.

I'm doing this by having a file named batcache-config.php, which is included in wp-config.php this way:

if ( file_exists( dirname( __FILE__ ) . '/batcache-config.php' ) ) {
    include( dirname( __FILE__ ) . '/batcache-config.php' );
}

And this is the content of my batcache-config.php:

<?php

// =================
// Batcache settings
// =================

global $batcache;

$batcache = array(
    'max_age'           => 300,
    'remote'            => 0,
    'times'             => 1,
    'seconds'           => 0,
    'group'             => 'batcache',
    'unique'            => array(),
    'headers'           => array(),
    'cache_redirects'   => false,
    'redirect_status'   => false,
    'redirect_location' => false,
    'uncached_headers'  => array( 'transfer-encoding' ),
    'debug'             => true,
    'cache_control'     => true,
    'cancel'            => false,
);

Maybe someone could come up with a cleaner way to do this.

I think this is a great plugin, and I hope this helps.

Avoid caching conflicts with plugins creating specific views with JSON requests

Some plugins, like the ActivityPub plugin, allow getting a JSON object representing your post when querying a post URL with an application/json header.

This proves problematic when using Batcache, since those requests end up being cached (a potentially good thing), but served back to regular site visitors.

Here is an instance of this happening:
https://fedi.jeremy.hu/@jeremy/statuses/01GVFG2QMBJTFH4VBJT2VZQ8NZ

It would be nice if such requests were at least not cached, or maybe cached separately so they could be served back later on.

No Batcache stats in head

I followed you instructions and I don't get stats in the head. I don't know if anything actually works ...

I am on shared hosting and I can active apcu extension in cpanel. I tried with php5.6 and php 7.0 .
Note : I have access to server with ssh, I can use php cli but no root. I use wordpress under bedrock from roots

under php 5.6 I get

$ php -v
ea-php-cli Copyright 2016 cPanel, Inc.
PHP 5.6.27 (cli) (built: Oct 16 2016 12:40:50)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies


$ php -i | grep memcache
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.default_timeout_ms => 1000 => 1000
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => standard => standard
memcache.max_failover_attempts => 20 => 20
memcached
memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.serializer => php => php
memcached.sess_binary => 0 => 0
memcached.sess_connect_timeout => 1000 => 1000
memcached.sess_consistent_hash => 0 => 0
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => 0 => 0
memcached.sess_lock_wait => 150000 => 150000
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => 0 => 0
memcached.sess_remove_failed => 0 => 0
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.store_retry_count => 2 => 2
memcached.use_sasl => 0 => 0
Registered save handlers => files user memcache memcached

How can I be sure that batcache plugin works ?
thanks

Undefined index and property notices

We’re seeing a lot of the following notices in debug.log:

[02-Apr-2015 21:33:01 UTC] PHP Notice:  Undefined index: HTTP_HOST in advanced-cache.php on line 388
[02-Apr-2015 21:33:01 UTC] PHP Notice:  Undefined index: REQUEST_METHOD in advanced-cache.php on line 389
[02-Apr-2015 21:33:01 UTC] PHP Notice:  Undefined property: batcache::$query in advanced-cache.php on line 391

The “Undefined property” notice is related to #36, but the other two we don’t see mentioned in any issues or PRs.

We wanted to touch base before submitting a pull request since these notices might be related to our setup, which is also running behind Varnish. Thanks!

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.