Hyper Cache

Hyper Cache for WordPress is the secret dream of every hosting provider!

Hyper Cache is a cache system for WordPress. I wrote it because my hosting provider was very low in resources, particularly on the MySql side. Hyper Cache solved all my performance problems.

Please consider Lite Cache as well. Lite Cache is a caching plugin with less feature but better performances and solves a number of issues of Hyper Cache, like the cleaning of pages generated on blogs with pages comments.

Hyper Cache main features

  • easy installation (from 2.5.9 version): just activate Hyper Cache and it works with a set of default values
  • every cached page will be served without accessing the database
  • gzip support for enabled browser with gzip caching (no page recompression on each request)
  • four invalidation modes
  • cache autoclean on configurable time interval
  • “urls to bypass” configurable (with two kinds of matching)
  • Global Translator plugin detection to avoid double caching
  • mobile browser detection with two separate caches (wp-pda plugin compatible)
  • low disk usage option
  • redirects and 404 caching
  • feed and home caching separate control
  • user agents configurable rejection
  • easy to install and configure, no file hacking or modification need
  • last but not least the author will always listen to you!

Hyper Cache versions are announced and described with posts tagged hyper cache versions.

To get help or ask questions, the preferred way is to leave a comment on Hyper Cache Help post.

Hyper Cache is very useful to me, and I think it’s very useful to many other bloggers. May be some of you are saving a lot of money on low cost hosting provider. With that in mind consider a donation: it will help me to develope new features for Hyper Cache instead of writing italian gossip to earn something with AdSense… Thank you!

Download and Installation

Download it from the WordPress Plugin Repository. Activate and go to the options page to configure and save the configuration even if some parameters are already set! If no warning messages appear, the cache is ready to work. Open your wp-config.php file and add the line of code:

define('WP_CACHE', true);

if not present, or, if present, modify it accordingly.

Pay attention: add that line of code just after the define(WPLANG, ”) not at the and of wp-config.php. In the file itself is explained to now modify it under a certain line.

Configuration

Expiration time

What means “expire a cached page after X minutes” and what’s the best value? Hyper Cache stores an html page in it’s repository. On each reaquest for a page, Hyper Cache checks how much old that page is. If the cached page is older than the X time (in minutes) specified, that page is not served by Hyper Cache, but “re-created” by WordPress (like if a cache system was not here).

Hyper Cache then restores the generated page. I use 1440 minutes for my pages (one day), but remember that a page can be cleared on special events (like comment or modification by the blog owner). You can specify a zero value to avoid any kind of cache expiration.

Invalidation methods, what’s the best?

There is not a best method, it all depends on your needs.

Method “all”. If you need a really coherent and updated blog, you can choose the method “all”: each action on posts (eg. edit), new comment submission and so on leads to a complete cache invalidation. But it’s the more expensive (for your blog, not for the cache). Remember that Hyper Cache (at now) doesn’t intercept the blogroll modification or the theme change. For the latter there are good reasons. So if you plan to make big modification to the blog, manually invalidate the cache.

Method “single post”. With this method, Hyper Cache invalidate only the cached page of a post modified (with the editor or when a new comment is added to it). The home/archives pages are invalidated too if specified with relative option flag.

Method “none”. The cache is never invalidated whatever action will be made (new comments, new posts, editing, and so on). This method can be good if you do very little modification to your blog. Obviously the cache still respects the expiration time.

URI rejection and matching criteria

There are times when a page or a post has to be served always from WordPress. Given the URI (URI is the right word) of that post, it can be added to the url to reject textarea. Let’s go with an example. You have a special page that has not to be cache, let it to be under the URI “/special-page”. So, enter that URI in the text area without quotes. The matching criteria is “if the current URI starts with one of the specified, just skip the caching system”. Read the criteria, you can use the partial URI “/special” and the special page will be still rejected.

What about if I need to reject a page with URI “/special” but cache the page with URI “/special-page”? Simply write the URI to reject surrounded with double quotes: “/special”. Hyper Cache will match exactly that page.

FAQ

I found no file in the cache folder. Try to set it to 777 permission level:for some reasons and on some provider Hyper Cache cannot write in that directory… there is no good explanations till now.

The options panel is saying my installation has problems! Deactivate and reactivate the plugin: some files need to be rewritten. Then **re-save** the configuration even if you didn’t make changes.

Why have I to use Hyper Cache and not other cache systems? I really cannot answer that question, but I wrote Hyper Cache to have an easly to install and crontrol cache system for WordPress that make me happy with a 4000 page views/day blog and a 12$/year hosting provider. Enough?

Where are the cache pages? In to the folder /wp-content/hyper-cache/cache: if you empty that directory the cache starts from zero.Do not delete the directory!

Why have I to donate? And how? There is chances that if you are using Hyper Cache you are saving a lot of money keeping you site in a cheap provider. This can be a reason. Or just because you find me a cool programmer and want me to keep in developing Hyper Cache and eating two times a day :-).

Help, support, bugs, feature request

Main place to ask support is here, but…

Any piece of software is great when it is really useful. Your request for new features, your bugs submission make the software better. No doubt, write me to info@satollo.net.

Some time software needs support to be effectively used. No doubt, write me to info@satollo.net and I’ll try to help out with your issues (clearly for free). I ask you only a little thing: be patience, I’m father of two little children, they have priority. :-)

How Hyper Cache works

On each request, the cache engine is called by WordPress. It checks if the html for this request is in cache and is still valid. If so the html page is returned and everything stops. WordPress calls the cache engine BEFORE any other kind of operations, so not plugins are activated, no database connection established, no queries executed. Il the page requested is not in cache, the cache engine “capture” the html produced by WordPress and put it on file. If you are the blog owner and you did login (so you have the WordPress cookies), you are always served by WordPress, the cache engine silently pass through. Hence to test the cache performance use a clean browser or delete all the cookies!

Hyper Cache is nice with mobile blogs

When a blog uses wp-pda to serve different pages to mobile devices a general cache system didn’t work, because it stores in cache the normal or the mobile version of a page: it dipends by the first caller. Hyper Cache uses the wp-pda detection code and can store different pages for different devices (PDA or iPhone). So it’s wp-pda safe. I think it can work with other “mobile” plugin, I’ve not tested yet. The cache works only with permalink active. It doesn’t cache POST request or GET request with parameters. This behavior let some plugin to work correctly.

Are AdSense, Analytics, MyBlogLog and so on affected?

No, absolutely. Those kind of services are delivered with javascript so they still work. My sites all use those services and all have Hyper Cache installed.

Gzip is no more a problem

If you are low of bandwidth and prefer to serve gzip compressed page to enabled browser… don’t worry. From version 2.0 gzip compression is working (if you provider has the gzencode function enabled).

Redirects and 404 not found are cached, too

WordPress sends a redirect on wrong URL or when a request doesn’t use the correct host (eg. domain.com instead of www.domain.com). Even if those are redirects and not served pages, WordPress and plugins will e activated by such requests, loading the database. If around the world there is a (wrong) link to you, every time it is used you will have two requests, not only one! Hyper Cache detects redirects and caches them using very little disk space. Not found pages are another problem.: when a request doesn’t match any page or post, WordPress creates the 404 page. This page is a normal html page that requires plugins, queries and so on. Hyper Cache, caches the 404 page and store only one file for this kind of requests. This behaviour optimize the missing resource requests, too, like images, css, javascript that are no more in your web space. Actually a WordPress blog without a cache system like Hyper Cache, will try to serve a page when a missing image is requested, creating a lot of load (it’s useful to check for missing resources in your blog tracking the sequence of requests made by the browser while loading a page: you can use Firefox with Live HTTP Headers extension).

Autoclean option

If a page is rarely requested, it stays in cache for days, using precious space. Enabling auto clean, the cache clear all the expired cached pages at the specifies time interval. It’s not a real cron job, but on sites with a minimum of traffic works nice.

From version 2.5.5 auto clean is very important, do not disable it!

Cache invalidation methods

You can decide if the cache has to be completely invalidated every time there is a change, has to be invalidated only the single post modified (there is exceptions with this method) or never invalidated (relay only on cache timeout for every single page).

Drawbacks

The cache tries to be as much quick as possible but that has some drawbacks. Specifically, when a page is in cache it is served directly and WordPress is not started. This means that no plugins are activated, so the ones that need to be called on each request (eg. for statistic) stop to give reliable results. This is a common issue to many cache systems, to say the truth.

Removing the plugin

Deactivate it. The deactivation removes some of the Hyper Cache files (see the technical notes). The wp-config.php is not changed, you can remove the “define” statement by hand: it doesn’t hurt, anyway.

Technical notes

The plugin create one file inside the wp-content folder. The file is “advanced-cache.php” and is required by WordPress. If the wp-content is not writable, Hyper Cache fails to install. A message should appear in the admin panel.

For plugin developers

You plugins can interact with Hyper Cache in two way: stopping it or dealing with the Hyper Cache buffer before Hyper Cache write it to disk.

To stop Hyper Cache to cache a specific request, simple declare a global variable:

global $hyper_cache_stop;

and set it to “true”:

$hyper_cache_stop = true;

That forces Hyper Cache to not save the current page. I use it, for example, on my Newsletter plugin and on my Protector plugin that create/modify pages in different way for each users.

The second wau to interact with Hyper Cache is to intercept the buffer before it is written to disk. To do that you need to register a filter:

add_filter(‘hyper_cache_buffer’, ‘myplugin_hyper_cache_buffer’);

where “myplugin_hyper_cache_buffer” is a function like the one below:

function myplugin_hyper_cache_buffer($buffer)
{
// work with buffer (it’s, usually, an UTF-8 string)
return $buffer;
}

I have not deeply test the latest feature, help me to test it if you have time!

This page, even if not complete, collects come configuration tips for Hyper Cache. If you have questions, please write me at <a href=”mailto:info@satollo.com”>info@satollo.com</a>.
<ul>
<li><a href=”#expiration-time”>Expiration time</a></li>
<li><a href=”#invalidation-methods”>Invalidation methods</a></li>
<li><a href=”#uri-rejection”>URI rejection</a></li>
<li><a href=”#faq”>Frequently Asked Questions</a></li>
</ul>
If you choosed to use Hyper Cache and are satisfied do a check of the advantages or the money saving it brings to you and consider to donate something: that will help me to continue the Hyper Cache developement.  <a href=”https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2595746″><img class=”alignnone” title=”Donate” src=”/english/images/paypal.gif” alt=”" width=”92″ height=”26″ /></a> Thank you!  <a name=”expiration-time”></a>
<h2>Expiration time</h2>
<strong>What means “expire a cached page after X minutes” and what’s the best value?</strong> Hyper Cache stores an html page in it’s repository. On each reaquest for a page, Hyper Cache checks how much old that page is. If the cached page is older than the X time (in minutes) specified, that page is not served by Hyper Cache, but “re-created” by WordPress (like if a cache system was not here). Hyper Cache then restores the generated page.  I use 1440 minutes for my pages (one day), but remeber that a page can be cleared on special events (like comment or modification by the blog owner). You can specify a zero value to avoid any kind of cache expiration.  Why it’s better to expire a page (even with a long time)? Because a page is not only the article text, but there are other information, like categories list with posts numbers, latest comment list, latest posts list and so on. With new content, new comments, those lists becomes “old”.  <a name=”invalidation-methods”></a>
<h2>Invalidation methods, what’s the best?</h2>
There is not a best method, it all depends on your needs.  <strong>Method “all”</strong>. If you need a really coherent and updated blog, you can choose the method “all”: each action on posts (eg. edit), new comment submission and so on leads to a complete cache invalidation. But it’s the more expensive (for your blog, not for the cache).  Remember that Hyper Cache (at now) doesn’t intercept the blogroll modification or the theme change. For the latter there are good reasons. So if you plan to make big modification to the blog, manually invalidate the cache.  <strong>Method “single page”</strong>. With this method, Hyper Cache invalidate only the cached page of a post modified (with the editor or when a new comment is added to it). The home page is invalidated too just to keep it coherent. But all the cache will be cleared if a post change it’s status from unpublished to published or from published to unpublished. That behaviour keeps all the blog pages updated (no links to article no more active or missing links to article just published).  <strong>Method “single page strictly”</strong>. I was asked to invalidate only and only tha cache page of a post when it is modified (even for a status change as explained), because there was no interest on having all the page perfectly updated.  <strong>Method “none”</strong>. The cache is never invalidated whatever action will be made (new comments, new posts, editing, and so on). This method can be good if you do very little modification to your blog. Obviously tha cache still respects the expiration time.  <a name=”uri-rejection”></a>
<h2>URI rejection and matching criteria</h2>
There are times when a page or a post has to be served always from WordPress. Given the URI (URI is the right word) of that post, it can be added to the url to reject textarea.  Let’s go with an example. You have a special page that has not to be cache, let it to be under the URI “/special-page”. So, enter that URI in the textarea <strong>without</strong> quotes. The matching criteria is “if the current URI <strong>starts</strong> with one of the specified, just skip the caching system”.  Read the criteria, you can use the partial URI “/special” and the special page will be still rejected.  <strong>What about if I need to reject a page with URI “/special” but cache the page with URI “/special-page”?</strong> Simply write the URI to reject surrounded <strong>with</strong> double quotes: “/special”. Hyper Cache will match exactly that page.  <a name=”faq”></a>
<h2>FAQ</h2>
<strong>The options panel is saying my installation has problems!</strong> Deactivate and reactivate the plugin: some files need to be rewritten. Then **re-save** the configuration even if you didn’t make changes.  <strong>Why have I to use Hyper Cache and not other cache systems?</strong> I really cannot answer that question, but I wrote Hyper Cache to have an easly to install and crontrol cache system for WordPress that make me happy with a 4000 page views/day blog and a 12$/year hosting provider. Enough?  <strong>Where are the cache pages?</strong> In to the folder /wp-content/hyper-cache: if you empty that directory the cache starts from zero.  <strong>Why have I to donate? And how?</strong> There is chances that if you are using Hyper Cache you are saving a lot of money keeping you site in a cheap provider. This can be a reason. Or just because you find me a cool programmer and want me to keep in developing Hyper Cache and eating two times a day :-). Or…  <a href=”https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2595746″><img class=”alignnone” title=”Donate” src=”/english/images/paypal.gif” alt=”" width=”92″ height=”26″ /></a> Thank you!

197 thoughts on “Hyper Cache

  1. poddys

    Our server is horribly slow with WordPress, but Hyper-cache serves up cached pages almost instantly.

    One problem though, in the footer of our pages we have a Twitter feed that shows how many minutes ago each tweet was posted. On cached pages the time does not change and new tweets do not show. The option to “cache feeds” is not set. Is there a way to get feeds like Twitter/Facebook to refresh on a cached page?

    Our site home page is http://www.drapertools.com/news/ if you have time to look and can see if anything is configured incorrectly.

    Our feeds do not usually update fast, so if this can’t be fixed I could set the cache to expire after 30 minutes, but because posts are not expected to change often I was going to set this to 4 hours.

    1. poddys

      It’s ok, I found the problem!

      The widget our theme uses to add the Twitter Feed to the page Footer is just outputting the HTML for the tweets at the time the page is loaded. There is no script to refresh it, so the caching works perfectly. I will need to make pages expire more frequently.

  2. charlenechen

    Hi, Stefano :
    my website is using hyper-cache. but i have a question.
    could i delete one posts from my hyper-cache ??(because there are 1000+ people on my site. if i delete all cache, the website will be broken.)

    i try to find the post hyper-cache number. i into the /wp-content/hyper-cache/cache and delete the file.
    but it dosen’t work. so please help me to delete one post cache (another methods).

    1. Stefano Post author

      My pugin work as is, probably that is another plugin that can be helpful I don’t know. About the error you have I don’t know, I don’t use that library of php on my plugin. Does the error disappears if you disable my plugin?

  3. Jakub

    This plugin is really good. I use it with SwarmCDN and it works without problem – my website loads under 1sec (before over 4sec). I have some ideas how to improve this plugin, maybe some of them would be added in future releases. There is a list:

    1) RSS caching
    2) Add clear link into admin bar (I know, there is a plugin for this, but it would be nice to add this to Hyper cache plugin)
    3) Schedule cache purge – add scheduler
    4) Cache only new content (older post are not cached anymore) – I like this feature from Lite cache
    5) Show total space of cached files in the settings (next to the page cached)
    6) Is https/http combination supported?

    Thank you again, I am looking for new version ;)

  4. Kevin

    First: great plugin, love this.

    I was wondering though; is it possible to do some sort of hole punching? In other words, not caching specific parts of a page?

    Cheers

    Kevin

    1. Stefano Post author

      No it’s not possible, since the plugin cache the generated HTML. Other plugins have some tricks to not cache part of the page, but I don’t know how they work and more, is that require to load the WP core system, it’s like to not have the cache…

    1. Stefano Post author

      Hi, my plugin DOES not inject any code, any coder can verify it just downloading the plugin source from wordpress.org. So I suggest you to really check you blog for other kind of hacks. Really.

      More, please instead of state that the plugin injects something (it’s so used and from so much time that this problem would be reported time ago), let me, if you want, to help you in finding the problem.

      The furst step is to delete the plugin to be sure it was not infected and reinstall it.

  5. Carlos

    Excelente plugin, trabaja bien , de lo mejor que he probado. Gracias amigo y buen verano.

    Excelent plugin, works fine, better plugin that I installed. Thanks and good summer my friend.

    Please update for ever, thanks

  6. My.com.bz

    Successfully installed hypercache! Thanks for such simple, one-click plugin.
    Also I’ve installed another plugin which re-generates hypercache every 24 hours. All pages which are expired from hypercache are re-generated and again kept in hypercache.

    1. Stefano Post author

      Restore the original wp-config.php (remove the line you added) and eventually remove the file “wp-content/advanced-cache.php”. But the problem is surely the modification of the wp-config.php. Do not copy the copy in the page since the single quotes are not valid: write if by hand.

      1. Bart

        I read somewhere: “If it does not add the code above then you have to add it manually. This code is needed for the plugin to work.”

        Probably I misunderstood you.

        I thought I had to add this line of code manually ANYWAY. But it does n’t seem the case anymore? Only in exceptional cases?

        1. Bart

          Carefully skipped the line and replaced the config-file, and subsequently removed the advanced-cache file, but the problem is still a blank WordPress-page with HTTP-error 500 (Internal Server Error).
          Uninstall WordPress and install again?

          1. Stefano Post author

            Hi, I need and FTP access to the blog and the blog address to find out the problem. As I asked before, try to send me the wp-config.php: if it’s the only file you changed probably it’s a matter to adjust it.

  7. silenkee

    Help! My server is centos + nginx + php5.3. Is there any problem with this environment? The Cleaning process time of hyper cache is always the time of activate the plugin plus 5 minutes. It never changed unless I reactivate the plugin.

  8. joao

    I installed W3TC and had many problems. Now I uninstalled HyperCache to use, but I can not remove the folder from the server cache. How do I do that? My Server is: Linux!

    1. Stefano Post author

      Which folder? If you cannot delete a folder on your file system, probably it has been created with a different user.

      Stefano.

  9. youstoryclub

    I wrote about my issue of using different style for different broser using php. I got the fix by javascript. Now I can use this plugin :-)

    <!–
    function hello(){
    var browserName=navigator.appName;

    if (browserName=="Microsoft Internet Explorer")
    {
    document.getElementById("demo").innerHTML="It works well when

    h1 is style for IE”;
    }
    else
    {
    document.getElementById(“dynamicstyle”).innerHTML=”It works well when

    h2 is style for non-IE”;
    }
    }

    //–>

    Default Text

  10. youstoryclub

    sounds very simple and logical for caching. I guess I can do and still have dynamic nature of my post (with delay of 24 hrs) – that is no issue.
    Please answer this:
    I have different fixes for different browser. (few issues with styles so I dynamically change style in php code for browsers such as if(is_IE) use_style_IE else use_style_all). Is there any way this plugin creates browser specific cached files and serve accordingly.
    Please give a fix/answer asap – thanks

  11. Asif

    Dear can u help as i install, but i think home page cache is active, or site indexing in Google almost after in 24 hours daily as Cached pages timeout was set 1440 .
    So what i do for this that Google index posts as posts write.

    Also i will check option :-
    Home caching
    DO NOT cache the home page so it is always fresh.

    or not checked. for home page not cache.?

    Thanks

  12. Jeff

    Hyper Cache is awesome… Thanks so much for it.

    I also have “Better WordPress Minify” installed, it was installed before HyperCache.

    Should I disable this minify plugin now? Does Hyper Cache take care of this function?

    Ane one more question.
    I also installed “DB Cache Reloaded Fix” with Hyper Cache but the testing I performed returned slower results with the two installed. So I disabled DB Cache.

    I know results will vary.. but any general comments on above?

    Thanks again for Hyper Cache, its blown away everything I’ve tried.

  13. Phil

    Hello,
    Just installed the plugin. Now i have access only to the home page but all other links from home page return a 404 (from the host, not WP).
    Within WP admin, when I want to preview a page, I also have 404 errors (from webhost, not WP)
    My install is a WP 3.2.1 in French with a specific theme.
    The define is installed in WP-config.
    Strange though, the cache folder is /wp-content/cache/hyper-cache/”cachefile”

    Please help…

    Philippe

  14. greg

    hey great plugin, can you consider a clear cache button at the top of the admin bar, so we dont have to dig into the plug to refresh, i think one of the other cache plugins did that.

  15. Pedrog

    Actually installing the plugins under load considerably,
    which is good, however there were serious problems on my site.
    1 .- In Google Chrome updated my page appears.
    2 .- Morzilla my home page appears with old posts.
    3 .- The worst, The Posts do not appear in Google is that search engines do not detect my “New Post”
    Please could give me a solution.

    my email is:
    pedro_galvez69@hotmail.com

  16. t_virus

    just wanted to know how to enable homepage caching. The option say “home caching” but the description says “DO NOT cache the home page so it is always fresh.”

    Should i check it or uncheck it? i need homepage caching

Leave a Reply