Code Monkey home page Code Monkey logo

simple-cache's Introduction

Simple Cache Build Status

Simple Cache was constructed after getting frustrated with the major caching plugins available and building sites with developer-only complex caching solutions that get millions of page views per day. Simple Cache promises the following:

  • Extremely simple one-click install. There is an on-off switch. That's it. No need to wade through 50 complicated settings.
  • Simple Cache makes your site run very fast so you can handle lots of traffic.
  • Extremely easy to delete. Don't like the plugin? You can remove it, and your website won't break.
  • Easily clear the cache if you need to.
  • Want to get advanced with object caching (Memached or Redis)? An advanced mode is available that will automatically setup Batcache and Memcached/Redis for you.

If you need your site to run fast, don't have time to mess with complicated settings, and have been frustrated by other caching plugins, give Simple Cache a try.

Issues

If you identify any errors or have an idea for improving the plugin, please open an issue.

License

Simple Cache is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

simple-cache's People

Contributors

benoitchantre avatar chesio avatar davidgoodwin avatar dependabot[bot] avatar gagan0123 avatar jaygooby avatar luisherranz avatar mustafauysal avatar psorensen avatar ranss avatar tlovett1 avatar

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

simple-cache's Issues

Isn't plugin compatible with woocommerce platform

I installed plugin and i happened to speed improvement but after two days customers started complaining that cart pages are not showing added products, also there are misc. behaviour of adding and removing products to cart. So i excluded URLs of cart page, my account page and checkout page from caching, but unfortunately this doesn't work. Do you have any solution for the problem.

Distorted pages only is caching is enabled

I notice regular distortion of some pages in multiple sites with the simple cache plugin.
All pages look fine and after a day or two, suddenly one or two pages are completely messed up.

I need to purche the cache and its all ok again.
I tested if I completely delete the simple cache, and it does not happen then.

Purching the cache fixes it temporarely, however it should not happen and I have no clue why this happens and how to fix it permanetaly.

Can you help sort this out please?

Thanks,
Annie

.Woff and svg caching

Hello,

Great plugin, but what does it cache?
When I look in google pagespeed insight I'm missing the .woff, .svg and some .png in my cache.

How can I fix this?
I've added this to the .htaccess, but it feels a bit double:

Header unset Pragma
FileETag None
Header unset ETag

---- IfModule mod_expires.c

AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"

----- IfModule

File owners don't need to be the same

Before you can enable caching, Simple Cache checks that the owners of a temp file and the WordPress files are the same here:

https://github.com/tlovett1/simple-cache/blob/1.5.6/inc/class-sc-config.php#L136-L149

... but with my host, they don't have to be the same. There's a "web" group that both my user (the owner of the WP files) and the Apache user are in. I can grant write permissions for folders to that group.

Moreover, I don't see anywhere else that fileowner() is used, so maybe this check isn't strictly needed.

If the fileowner check is bypassed, everything else works normally.

I'm not sure this is a legit issue or just some weirdness with my host, but thought I'd file anyway.

not recognizing memcached on php 7?

In plugin settings I get this:

Neither Memcache or Redis PHP extensions are set up on your server.

Setup (used laravel forge):

  • Memcached Version 3.0.0b1
  • PHP Version 7.0.4-1+deb.sury.org~trusty+1

Thoughts?

Changing Redis Database number on the same webserver

Hello,
When using Redis in memory caching, Simple Cache use standard the Redis Database number 0.
Is it possible to change this Redis Database number to 1, 2, etc.? And how to do that?
Because now I can’t using Simple Cache on a second WordPress website on the same webserver with memory caching with Redis. Simple Cache will use the same Redis database 0 so, this will result in the same cache content from the first website.
Is there a configuration option to indicate that Simple Cache can use with Redis an other database then the default number 0?
There is another plugin “Redis Object Cache By Till Krüss” where you can adjust the connection parameters by define some constants in the wp-config.php file such as: WP_REDIS_DATABASE. This is a good solution. Is that also possible?
Thanks in advance.
Best Regards.

Problem with cached assets loading via https

Hi there. First off, awesome work on this little plugin! I've been using it on a couple of websites I manage for over a year now with good results.

However I serious issue has recently cropped up: For whatever reason, the cached stylesheets of one of the websites I manage are randomly being loading via https instead of http. It doesn't happen to all pages of the website, only some pages, some of the time, at random.

Purging the cache always solves the issue, but only temporarily.

For the immediate time being, I'm forced to use a different caching plugin.

I know you said you don't check the WP support forums, but this issue is documented at the following links:

https://wordpress.org/support/topic/stylesheet-not-loading-sometimes-on-some-posts/

https://wordpress.org/support/topic/ssl-conflict-with-simple-cache-messed-up-layouts/

Wrong admin notice

Somehow I'm getting
screen shot 2016-05-18 at 09 41 08

Meanwhile I'm seeing
define( 'WP_CACHE', true ); // Simple Cache

in wp-config file.

WebP support

When .webp images exist, it would be nice to generate a specific cached file with src pointing to .webp images.

Ability to preload cache

Thanks for this plugin, I'm really loving the simplicity of it. Would it be possible to add something simple which preloads non-cached or expired pages?

Multisite + cache = broken images

We've used this plugin on a few single instance wordpress installations and it has worked well. I've hit a bump trying to get it to work on a multisite instance. The site is setup as multisite "subdomains" (so xxx.domain.com, yyy.domain.com)

Something seems to be conflicting with the rewrite rule when caching is enabled.

With caching enabled, this file will be broken
http://.../files/2012/10/Events.jpg

With caching disabled it's fine.

Here's the .htaccess for reference - nothing odd there I don't think.

# BEGIN WordPress
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

</IfModule>
# END WordPress


#prevent direct php execution in wp-content folders
<IfModule mod_rewrite.c>
RewriteRule ^wp-content/.*\.(php|php3|php4|php5)$ - [R=404,L,NC]
</IfModule>

The error it throws is a 500 (server error) which would seem to indicate that wp-includes/ms-files.php is involved somehow, but there's nothing in the error log about it.

The oddest part is that this works fine in Firefox but not Chrome or Edge. I've cleared caches both locally and on the server to no avail.

Any thoughts?

Selective cache refresh

At the moment, the entire cache is wiped out when a new content is published.

It would be a nice improvement to refresh the cache only for the necessary for URLs that have to be updated.

Cache Control Headers

Hi, after enabling this plugin my cache control headers are not setting. I have a plugin which sets these for telling the cdn how long to cache something for, but these disappear when the plugin is active.

Redis vs Memcache speed

Hi and thanks for the plugin.

I am using SimpleCache for DB (not page) caching only and have done some analysis of Redis vs Memcache performance. My (simple) understanding of DB caching is that Redis is superior in its method of storing and retrieving cached items, but using Query Monitor I have discovered the following results:

  1. 0.53S 44,571KB 0.0063S 67Q (dashboard, no cache, buddypress|bbpress)
  2. 0.46S 37,618KB 0.0045S 49Q (homepage, no cache, buddypress|bbpress)
  3. 1.60S 45,463KB 0.0054S 58Q (dashboard, redis, buddypress|bbpress)
  4. 0.46S 37,869KB 0.0052S 50Q (homepage, redis, buddypress|bbpress)
  5. 0.53S 43,075KB 0.0013S 10Q (dashboard, memcache, buddypress|bbpress)
  6. 0.42S 36,118KB 0.0005S 3Q (homepage, memcache, buddypress|bbpress)

These tests were performed on a vanilla WP 4.7.2 running 2017 theme with BuddyPress and BBPress as test plugins because, combined, they contribute a notable load. SimpleCache was disabled/enabled between cache changes and each test was performed 3 times with the last result taken for each.

These results show that Memcache is significantly faster, outperforming Redis by several factors both in execution time and query count. Result 3) is very odd because it shows the Redis cache slowing Wordpress' dashboard down from 0.53s without any cache to 1.6s with?

Not sure if this information is useful or not, but I would very much appreciate an understanding of why the SimpleCache Redis implementation is so much slower than Memcache which appears to buck the general accepted suggestion to move from Memcache to Redis for increased speed and flexibility.

BBpress Purge cache

i add bb press purge cache please add

            add_action( 'bbp_theme_after_topic_form_content', 'purge_post_on_update' );
            add_action( 'bbp_theme_after_reply_form_content', 'purge_post_on_update' );
    /**
     * Setup hooks/filters
     *
     * @since 1.0
     */
    public function setup() {

        add_action( 'admin_notices', array( $this, 'print_notice' ) );
        add_action( 'pre_post_update', array( $this, 'purge_post_on_update' ), 10, 1 );
        add_action( 'save_post', array( $this, 'purge_post_on_update' ), 10, 1 );
        add_action( 'wp_trash_post', array( $this, 'purge_post_on_update' ), 10, 1 );
        add_action( 'comment_post', array( $this, 'purge_post_on_new_comment' ), 10, 3 );
        add_action( 'wp_set_comment_status', array( $this, 'purge_post_on_comment_status_change' ) );
        add_action( 'set_comment_cookies', array( $this, 'set_comment_cookie_exceptions' ) );
                add_action( 'bbp_theme_after_topic_form_content', 'purge_post_on_update' );
                add_action( 'bbp_theme_after_reply_form_content', 'purge_post_on_update' );
    }

CI

Please introduce Travis and some basic unit tests and WPCS maybe.
Thanks.

Exceptions

Would love to be able to remove entire categories or folders, ie /category1/ and all pages within this URL would be exempt from cache.

HTML labels not working on the settings page

The following <label> tags aren't working on the settings page:

  • Enable Page Caching
  • Expire page cache after
  • Enable gzip Compression

For example, the for attribute for the 'Enable gzip Compression' label is sc_enable_gzip_compression, but the id attribute of the <input> element is sc_enable_gzip_compression_advanced.

That's why nothing happens when clicking on the label.

Password protected posts are cached

Steps to reproduce:

  1. Visit a password protected content: you see the password field, nothing is written to the cache.
  2. After entering a valid password, you see the content, this content is written to the cache.
  3. If you or someone else visit the page, the content is displayed directly instead of a password field.

The content of password protected posts should not be cached.

Comment clash with No Captcha error condition

Applying No Captcha to Wordpress comments. When entering a comment and NOT clicking the No Captcha button (creating an error condition), I get this:
"Fatal error: Call to undefined function WP_Filesystem() in /home/cinepedia/public_html/wp-content/plugins/simple-cache/inc/class-sc-advanced-cache.php on line 56"
Can test for yourself at cinepedia.com. Click on post title to display comment section.

DONOTCACHEPAGE

Please support WooCommerce's DONOTCACHEPAGE contanst.

No caching HTTP headers for cached pages

Hi, Taylor!

Thanks for this amazing plugin, it's really simple and useful! But it seems that cached pages have no Last-Modified, Expires and other HTTP caching headers (but they exists for non-cached versions, I think WP is generating them by default). The caching is enabled in admin page (the first option is "Yes", all other options are in their default states).

Is this a bug? Or am I missing something in config?

Mixed content

In some situations, it is possible to serve a cached file which would produce mixed content.

You can reproduce this situation with the following configuration :

  • a valid certificate is installed
  • WordPress is configured to use https
  • contents can be accessed with http or https (no https redirects)

and the following scenario: 

  1. the first visit is done with http
    → the cache contains http links to the assets
  2. another visit is done with https
    → the cache is served with https but contains http links (mixed content): your browser doesn't load the assets

Write access to wp-config.php

Since it is possible and perfectly valid to have the wp-config.php owned by another user, I think your way of handling the missing write permissions is misleading. Because now I have a non-dismissable error message at the top of my page although the cache is working just fine.

My proposition is:

  • Seperate the error message for wp-config.php and wp-content
  • Only check write-access when actually needed, i.e. if WP_CACHE is true, we don't need to write to wp-config.php
  • As mentioned in #19 the file owner of the files should not matter as long as the cache directory is writeable?!

Quick Question

Hi, heard great things about this plugin so wanted to try it out!

I have pages that change infrequently so want to set a long expiry time, e.g, 1 month, but my homepage changes regularly.

Could you tell me, will my homepage cache be regenerated when it's updated if i set the cache for 1 month?

Thanks

Option to show cache to other than admin?

I have posted this quesstion on the support forum and was asked to put it here:
[https://wordpress.org/support/topic/option-to-show-cache-to-other-than-admin/#post-8632555]

It is handy to let other “roles” like a client making smaller changes or updating posts, also be able to purche cache so they can see the actual changes after they make them.

There are multiple times the cache clearly needs to be purched manually.

Simple post and page updates where only some text or images are changed, do not need manual clearing of the cache. However,often after a core or plugin update, layout can get completely messed up, and only purching the cache, shows the normal non messed up layout.

Or for example, changing some colours or layout in customizer, only can be seen after I manually clear the cache…

Would be great if this could be added? love this plugin!
Annie

Blocking PageSpeed and GetMatrix

Blocking PageSpeed and GetMatrix

Installation of the plugin caused problems with pagespeed and getmatrix the two speed analyzes were blocked.

PageSpeed Message:
There was an error fetching or analyzing the page. To dispense

GetMatrix Message:
Analysis Error

An error occurred fetching the page: HTTPS error: SSL connect attempt failed error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error

There may be a connectivity issue between your server and the GTmetrix test server. Please login to try testing from another test location or try again later.

Print: http://www.screencast.com/t/js4a3c1De5

PHP Notice: Use of undefined constants FS_CHMOD_FILE and FS_CHMOD_DIR

Hi,

I get notices in my debug.log about undefined FS_CHMOD_FILE constant in simple-cache/inc/dropins/file-based-page-cache-functions.php and undefined FS_CHMOD_DIR constant in wp-admin/includes/class-wp-filesystem-direct.php.

I found out that these two constants are conditionally defined in WP_Filesystem. However, Simple Cache does not initializes WP_Filesystem for file-based page cache, but uses WP_Filesystem_Direct directly, so in my opinion these constants have to be (conditionally) defined directly in the sc_cache() method.

Cheers,
Česlav

Security issues

Hi Taylor,

I found two security issues in Simple Cache that I think you should be aware of:

  1. Any request to a valid URL with a random query string results in a new cache file being created, because query string is part of REQUEST_URI and therefore is being used in file name of the new cache file. This opens door to a possible DOS attacks (sometimes called cache flooding).
  2. It is possible to manipulate cache to serve a different page than requested using requests with specially crafted URLs. I can't imagine a scenario when this could be misused, but I believe there are people with far better imagination than me :-)

Both issues can be prevented by one of the following:

  1. Not caching any requests with non-empty query string
  2. Better sanitization of REQUEST_URI in sc_get_url_path() function.

I personally favour the former, as it generally makes sense to me to avoid caching request that are in essence "dynamic", but I don't know whether your decision to cache requests with query string is deliberate or not; obviously, not caching such requests makes Simple Cache unusable for websites without pretty permalinks.

Cache wiped when saving draft

I think it’s a bug : when I save the draft of a not yet published post, the whole cache is wiped.

It should not be the case, not until I publish the post.

Simple Cache can't create or modify needed files

Simple Cache worked fine for me until I temporarily deactivated it (to test possible incompatibility with another plug-in). When I reactivated it, I got the error message:

"Simple Cache can't create or modify needed files on your system. Specifically, Simple Cache needs to write to wp-config.php and /wp-content using PHP's fopen() function. Contact your host."

After researching online, I went into the wp_config file and made sure define('WP_CACHE', true ); was in there. But I still get the same error.

Do you have any suggestions?

Thanks.

Permissions issue

Hey @tlovett1

I'm having trouble with having the plugin work. It shows that wrong permission issue for the fopen() function. I've set all the right users and permission, 775 but it still won't work. I had to drop the plugin for now and install WP Super Cache which works fine under these permissions.

Could you have a look at this?

Windows carriage-return in wp-config.php

After writing the wp-config.php the file has windows line endings. In my opinion this should be replaced by unix line endings (I suppose most WordPress sites are hosted in a unix environment).

Stylesheet not loading sometimes on some posts

This is a great simple plugin t use!
However, about four months ago (during 4.7 cycle), I had to deactivate it at my site.

The reason was the theme's stylesheet not working on some posts (randomly), sometimes .

Then I found out if clear the cache of “simple cache” plugins, the stylesheet begins to work fine.

I use child theme of the default twentyten theme.

Is there anyway to find out what might be causing the issue, because I would like to start using this plugin again.

Thanks

Batcache

I put the dropin batcache.php in /wp-content

I see it exists in your /inc/dropins as well. Pardon my ignorance but which one controls the batcache if you want to change for instance - var $max_age = 3600; ?

Awesome performing plugin.
Thanks
stu

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.