Lite Cache

Lite Cache is an efficient cache plug-in for WordPress. It’s simple, like Hyper Cache but easy to configure.

If possible use the forum to ask for help.

Lite Cache is compatible with gzip compression and handles it automatically.

Lite Cache works even with commentators, people who left a comment in the past. Other caching plug-in usually are not able to serve cached content to commentators. This is of great importance for blogs with many returning commentators.

Lite Cache can detect mobile devices, create a separate cache for them and can force a secondary template for mobile devices.

Lite Cache can cache the pages even when the visitor is a logged in user, but it is not recommended and the option should be enabled ONLY if you know what to change in your theme to avoid disaster.

Lite Cache is actually used on a blog, www.periodofertile.it, which counts over a 1,500,000 page views per month and is saving the little virtual server where it is installed (with other two blogs). It is used on my personal Italian blog too, www.zeroblog.it, if you would see the page signed by Lite Cache.

Install it and go to the options panel to find how to configure it.

Download

Get Lite Cache from WordPress Plugin Directory.

The Vary header

When a site serves different page versions to different devices (usually desktop and mobile) Google recommends to add a Vary header. This header, in few words, says: pay attention that the URL requested can put out different content depending on … (and the value of the Vary header determines what is the discriminant).

Lite cache sends this header when it manages the compression and when a different mobile theme is used, to be fully compliant with Google responsive design recommendations.

More about:

F.A.Q.

Is it compatibile with multi-site installation?

Never tested, but I think it is not compatibile is you use third level domains.

Is it compatible with plug-ins designed to detect mobile devices?

Yes if the list of mobile agents configured on Lite Cache is the same of the one configured on your mobile plug-in.

How does it work?

Lite Cache grabs the generated page HTML of almost any page of your blog and stores it on a disk cache. It grabs the
page only on first request, the cache content is not generated on first activation.

Lite Cache, dfferently from other cache systems, operates even when the blog is surfed by people who commented the blog
and grants (when possible) to fill the comment box fields with user’s data without exposing it to other visitors. If your theme
blocks this feature, I cannot fix it and the comment box fields will be left empty.

Lite Cache does not operate under some circumstances:

  1. When a not found page is generated (404 error)
  2. When the feed is generated
  3. When a WordPress user is logged in and surfs the blog if not explicitely enabled
  4. When the virtual robots.txt page is generated
  5. When a request is a trackback from other blogs
  6. When a plugin force the global variable “$cache_stop” to true (read more on my standard proposal for cache systems)
  7. When a request matches one of the excluded paths

When the cache is cleaned up (invalidated)?

Lite Cache cleans up the cache when the blog content is changed, with these rules (no, they are not configurable):

  1. When a post is changed its cached page is removed with the home, tags, type, current year, feeds and categories cached pages
  2. When a post gets a comment only its cached page is removed (that removes the pages comments and the comment feed as well)

How can I check if it is working?

  1. Open your browser and go to the blog admin side.
  2. Log in.
  3. Log out (on right top there is that option).
  4. Open a blog page.
  5. Reload it a couple of time.
  6. Look at the page HTML source: last line should be looks like <!– lite cache… –>

It does not work!

Have you tried to follow the steps on previous answer?

It still does not work.

May be Lite Cache is not compatible with your installation: do not use it. My blogs use it and it works on them. It happens.

Does Lite cache correctly manages the paged comments?

Yes, it does.

Are feeds cached?

Yes, they are and there is no option to avoid that.

Can I use a different folder for the cache?

Yes, under advanced options you can set that. Pay attention to “point” to a writable folder otherwise no file will be written. This option is useful when you have a partition which is quicker than the one where the blog is installed or to avoid to have cache file inside the blog folder (that should be excluded from backup and that, usually, use a lot of disk space).

There is an option to stop the cache for specific agents?

No.

There is an option to stop the cache for specific cookies?

No.

There is an option to stop the cache for specific URLs?

Yes. On administration panel you can set a list of URLs (to be correct URIs) to be excluded from the caching process. every requested page address is matched with the list of “to be rejected” URIs and it “starts with” on of them is skipped.

There are options to control the cache at post and page level (eg. on editing panel)?

No.

Can I avoid to cache the home page?

No.

Can I stop the cache for Google Bot or other search engine bots?

No.

Does Lite Cache caches images?

No, it has no meaning, not only for Lite Cache usually for every cache system. If with “caching images” you means a CDN integration, no there is no CDN integration.

Does Lite Cache minify or cleans up the HTML code?

No, even with tidy installed, it creates too much issues with XML snipped from Facebook and others. I definitively removed it.

Does Lite Cache minify Javascript or CSS?

No.

Does Lite Cache can use CDNs?

No.

Can be used in conjunction with Apache Rewrite Engine and the .htaccess?

Yes, when you save the options the snippet of rules to copy inside the .htaccess. Not all Lite Cache options works using .htaccess rules. Some user’s reported a more efficient caching without using all that rules on .htaccess, but I really don’t have scientific tests.

It is mandatory to modify the .htaccess?

No, and if you don’t know how to modify it, please don’t try to edit the file. If you want to try, keep a backup. If the site does not show up after an .htaccess modification, restore the original .htaccess.

Does Lite Cache is compatible with mfunc?

No, it is not.

How can Lite Cache stopped on a specific page by third party plug-in or short code?

Any plug-in that want to avoid a specific page to be cached, must set to false the global variable $cache_stop. For example I force it to false on some of my plug-in short codes when they generate different output depending on who is navigating the site.

How to filter the cached content of a page

Register a standard WordPress filter with name “cache_buffer”: the buffer is passed on your function and your function can process it and return the modified content that will be stored. An example:

function my_cache_buffer_filter($buffer) {
return $buffer . ‘&lt!– I was here –>;
}

add_filter(‘cache_buffer’, ‘my_cache_buffer_filter’);

Can I set Lite Cache to cache only newer posts?

Yes, you can set Lite Cache to not store old posts into the cache. Usually this is recommendable with very big blogs which do not have traffic on old posts but only on the newer ones. It saves a lot of disk space and avoids that a single visit on a old post (by humans or bots) to use disk space.

The administrative panel is translated or translatable?

Actually not.


38 thoughts on “Lite Cache

  1. hydn

    I’ve found that this plugin does not remove any files from the cache. After a month I was to 2GB of cached data. To fix I’ve had to setup a cron script which runs nightly and deletes files only than 1 day.

    eg:
    find /home/hydn/public_html/wp-content/cache/lite-cache/ -mtime +1 -exec rm -f {} \;

    I’m using all default settings (TTL is set to 1 hour). I’m not using .htaccess.

    If you confirm this as an issue I will donate towards fix.

    thx

    1. Stefano Post author

      Hi, it’s not possible lo run a linux command from a blog… or better is not a general available solution. shared hostings do not allow that, windows hostings do not have that kind of command. The only viable way is to run a PHP process… If possible I’ll add it on future versions.

      In the meanwhile for your blog, you can run such a command with a cron.

  2. Franco

    Hi Stefano
    Thanks for this plugin and the last update

    I do have a question :-)

    If i set the “Cached pages will be valid for to forever (0)”
    Will this still be valid ?

    When a post is changed its cached page is removed with the home, tags, type, current year, feeds and categories cached pages
    When a post gets a comment only its cached page is removed (that removes the pages comments and the comment feed as well)

    Also another question:

    If a post is changed like
    “When a post is changed its cached page is removed with the home, tags, type, current year, feeds and categories cached pages”

    Im correct when I say that all unchanged post stay in cache ? does it work as well with cache forever ?
    or does the whole cache gets killed?

    Sorry to be a bit complicated…..
    ————————————————
    You cache is so cool i really love it
    We have a page with like 14k of posts on a small virtuell server

    pingdom and other speed checker mostly say speed below 3 secs… lol so awesome.
    even we dont have yet setup CDN yet for the images

    If you like to see the page look at my email for the url :)

    1. Stefano Post author

      When a post is modified the post, home, categories, …, are invalidated. Always. Setting the expiration to 0 means that, if a post is in cache and never changed, it won’t be refresh automatically. If the expiration is set, it will stay in cache at most X hours.

  3. Jonathan Timar

    Hi Stefano,

    I have discovered that when returning commenters leave a comment on my blog when Lite Cache is activated, it pre-fills their name at FIRSTNAME+LASTNAME, the plus sign appears where a space should be.

    Disabling Lite cache stops this from happening. How can I fix it?

    Thank you,
    Jonathan

  4. Dorin

    Hello, Stefano,

    I think Lite Cache is a great plugin. I have used before another very good plugin, Quick Cache, but Lite Cache even promote my site with 9-10 points on Google Speed Test!

    Unfortunately, I have two problems using Lite Cache – and at least the first one seems a major one to me.

    1. With Lite Cache, some pages on my site (WP & BP) that I want to keep only for logged-in users: e. g. Activity, Members, Groups – now are revealed to everybody (the plugin I use for hiding these pages for non-logged visitors is Private Pages). I added these pages at “URLs to exclude from cache”, but it seems it doesn’t work. Any suggestion on what happened, please?

    2. For Mobile, I keep it on Disabled Mode, because every time I choose otherwise, I mean the options for separate cache or bypass, I get a 503 Service Unavailable error for the mobile (the Google PageSpeed Insights gets
    “PageSpeed Insights received a 503 response from the server. To analyze pages behind firewalls or that require authentication, try the PageSpeed Insights browser extension.”.
    Do you have any idea why is that?

    I would appreciate any solution, because I really want to use Lite Cache.

    Thank you!

    Dorin

    1. Stefano Post author

      The 503 can be a plugin bug, I need to check the code. To disable some page, you can add their (partial) URLs to the configuration.

      When a user is logged in the cache should be inactive, did you activate it even for logged in users? If so, disable it.

      1. Dorin

        Thank you for your reply!

        No, of course, I didn’t activate the plugin for the logged in users – that, in fact, puzzled me more about this unexpected problem.

        What do you mean by the partial URLs? I’ll tried many times with the entire urls of the pages, and also only with their names in the urls – unfortunately, with no good result. (It seems like the cache option for logged-in users is active – but it is not).

      2. Dorin

        Moreover, when I log in (as admin or regular user, doesn’t matter) from the front end, many pages (not all) looks like I am not logged (but I can see the pages, even if I am logged in or not). If I refresh them, one by one, finally it looks on each like I am logged in. Very strange!

        1. Dorin

          I managed, one way or another, to solve the first problem – it was, I guess, because of a conflict with CloudFlare, I don’t know exactly why and how, but, anyway, with strange and unexpected errors. I simply removed CloudFlare.

          I am very glad to use now LiteCache, it is great and simple – and really speeded my site in a spectacular way. According to my (limited) experience, it is the most effective cache plugin that I used.

  5. Aamir Rizwan

    Great plugin. Compared to Hyper cache it improved server response time by 300-400 ms and also the total page load time.
    What is the purpose of .htaccess code? From my limited knowledge I think it is for pre compressing pages. And I’m not using mobile mode so can I omit #mobile and #mobile gzip section ?

      1. Stefano Post author

        “Minification” should not break the CSS. But if the CSS is not perfect it may happens (or if the plugin is not updated with the latest CSS standards).

  6. Dominik

    Thanks for this great Plugin!

    I have a question. It seems that Lite Cache add a Java Script just before the <!– lite cache…. comment in all my documents. What is this and how can i disable it?

    Thanks a lot for your great work!
    Dominik

    1. Stefano Post author

      That javascript is important. It lets the cache to work even when the surfer is a person who already commented in your blog. Most of the caches do not work with visitors who left a comment in the past since they have a cookie which is used to pre-fill the comment form.

      The javaScript deals with that, make the cache more efficient.

      1. Dominik

        Thanks for your reply. I deactivate all comments on my site (just a Portfolio). Can i deactivate this Java Script or doesn’t work the Plugin without it?

        Thanks for your help :-)

  7. Hazlo

    Hello Stefano,
    Your plugin works perfect on my site.
    I have another question now, about the cache : Is it good to disallow it in the robots.text or not? Is there a risk of duplicate content?
    Thanks in advance for you answer and for your plugin which is so useful.

    1. Stefano Post author

      Hi, what kind of disallow would you add? For the cache folder?
      If it is for the cache folder, it’s good to disallow it, but files on that folder will never be indexed.

  8. TJ

    I was using lite cache and loved it. However something really strange happened today and now when I reactivate lite-cache I can get the admin part to load up when going to settings > lite cache. I tried removing and reinstalling from the plugins directory. Is there another place in the database or in the file structure where something might have been corrupted?

    1. Stefano Post author

      Delete the file wp-content/advanced-cache.php and the folder wp-content/plugins/lite-cache and the plugin will be totally removed. Then you can reinstall it.

      Strange thing anyway…

    1. Stefano Post author

      But do you find them in the lite cache folder? Or are they physical files? Anyway the url to exclude are

      /sitemap_index.xml
      /post-sitemap.xml
      /page-sitemap.xml

  9. Hazlo

    Hello Stefano,
    First of all, many thanks for this very useful plugin. I’ve posted a couple of questions on the WP Support but got no answers till now so I dare to ask you directly here.
    My first question is about how to set up the valid time of the cache.
    I’m not a pro and I don’t know if a very short time is better , or a few hours, etc.
    My site has a low traffic, and is hosted on a shared server that runs with LiteSpeed.
    Since I added your plugin my loading time is much shorter and I’m very glad of that.
    See the test : <a href="http://www.webpagetest.org/result/130430_Y3_75eb68e0b7251c04aa87168cb0160f63/&quot;
    But I wonder about why I get grade D on cache static content?
    Any advice for those two questions?
    Thanks a lot, in advance.
    Hazlo

    1. Stefano Post author

      Hi, sorry is I missed to answer on wordpress I need to check if I enabled to notifications. About static content it has nothing to do with caching of html, it refers to header youy should set on server to enable caching at the browser level. The configuration on apache require mod_header or mod_expire.

      1. Hazlo

        Many thanks Stefano for answering. I’ll check the server cache with my hoster.
        But could you give me an advice about how to set up the valid time in the plugin?
        I tried 4 hours and finally I’ve set it to 24 hours. Is that ok for a small site like mine?
        Thanks a lot for your patience!

        1. Stefano Post author

          There is not a real answer, you can leave the value to 24 hours or more. On some blogs I set it to zero (it means indefinitely).

          Of course if you have widget which show the latest post, more old is the cached age more old are the listed posts. This is probably the main measure to decide the number of hours.

  10. Baron Bela

    Good plugin! But there is one big problem when categories which have not base (null-base). It’s seems to me the best way is to get path of each post’s category and to clear it’s cache separatly. Sorry for my english(

    1. Stefano Post author

      The plugin know nothing about category with no base, and probably cannot detect them. Category with no base are usually managed by specialized plugins. It’s your case?

Leave a Reply