Website DIY - tricks and solutions

Comet Cache and GeoIP: enable caching by page/visitor country instead of just page


Comet Cache (previously named Quick or Zen Cache) improves performance by serving a snapshot (cache) of a previously visited page, making it unnecessary for WordPress to generate a fresh “new” page for every visitor.

This causes the display of wrong content on sites that use country geo-location. This page should display your National flag . However, if the page was “first” requested by someone in Albania, Comet Cache would, instead, serve you the cached page with the Albanian flag. The Country Caching extension solves this problem.

In this article:

1. What the Country Caching Extension does
2. Installation and set-up
3. How do I know its working?
4. GeoLocation, and how to auto-update
5. Problems and Issues
6. Auto & Manual Uninstall
7. Warning

1. What the Country Caching Extension for Comet Cache does:

  • It builds an add-on script which uses an official Comet Cache interface to cache by page/country instead of just page. You can limit separate caching to specified countries.
  • It provides the GeoIP look-up to enable Comet Cache to determine the visitor’s country.

2. Installation and set-up of the Comet Cache Extension

Install in the normal way via “Dashboard->Plugins->Add New” and search for “Country Caching Extension“; or download from WordPress.Org.

Quick Setup:Dashboard->Country Caching“. Check the ” Enable CC Country Caching add-on” check box, and click save.

You can separately cache for ALL countries (Country Codes box empty).

Alternatively, you can allow most visitors to see the same “normal” cached page, and just specify specific countries that should have their own separate cache e.g. specify “FR,CA” if only visitors from France and Canada should see content different to the “normal” page. You can also define a group of countries that will share the same single cache.

3. How do I know it is working

Visit pages on your site using a couple of Browsers. Check content is as expected for that country (if not you may need to clear existing Comet cache).

You can also test by visiting Locabrowser.com to simulate visiting your site from different countries or by using Opera VPN, or online Country proxy servers.

Comet Cache inserts hidden HTML comments at the bottom of pages and we can tell from these whether country caching is working.

<!-- Comet Cache file path: /cache/quick-cache/cache/http/example.com/somepage.v/US.html -->
<!-- Quick Cache file built for (US http/example.com/somepage/) in 0.43448 seconds, on: Dec 3rd, 2014 @ 7:21 pm UTC. -->
Snapshot for visitor located in the US.
NOTE: this WILL NOT BE DISPLAYED if you are using a plugin or CDN that is set to MINIFY HTML

  1. After installing Country Caching go to Comet Cache settings and clear the existing cache.
  2. Open a page on your site using a “virgin” browser (see below)
  3. View the source for the page e.g. if using IE right click on the page and select “view source” option
  4. Check the Comet Cache comments at the bottom of the source.

If Country Caching is working you will see the country code for your location is used as a suffix by Comet Cache (see “US” country code highlighted in yellow in the above example).

Testing GOTCHAs:

  • Comet Cache does NOT cache pages if you are (or have PREVIOUSLY been) logged in.
    To test, use a browser that has NEVER been used to log in to your site (if you can’t do this ensure you are not logged in and cookies are deleted before viewing a page).
  • If you are using a plugin or a CDN like Cloudflare with an option set to minify HTML then you won’t see these comments.

N.B. if you have limited separate caching to specific countries then ensure your country is in this list during your tests, otherwise you will (correctly) see Comet Cache comments indicating the normal cache is being used.

4. GeoLocation, and how to auto-update:

If you use Cloudflare and have “switched on” their GeoLocation option ( see Cloudflare’s instructions ) then it will be used to identify visitor country. If not, then the Maxmind GeoLite2 Country Database, included with this plugin, will be used.

Updating The included Maxmind Country/IP range data files will lose accuracy over time. If you would like an automate update of these files then install the Category Country Aware plugin (here on WordPress.Org). Even if you don’t use any of its other features, it will automatically update GeoIP data “every 3 weeks”.

5. Problems and Issues

No problems have been reported in the plugin’s support forum for 3 years. If you do experience problems then the “Configuration & Support” settings tab should provide information needed for support requests.

If the plugin is unable to save the generated add-on script it is probably due to your server’s permissions. Checking the “List plugin values/Maxmind Health/File Permissions” check-box (see above) should provide information about your server’s current file permissions.

Read Smashing Magazine’s article on WordPress Folder and File security requirements for different servers; and how to change WP Folder and File permissions.

Directory Permissions: Assuming you have a “typical” server, permissions for your WordPress “wp-content/” and “wp-content/ac-plugins/” (if it exists) folders should be set to 755 on a shared server, and 775 on a dedicated server; do NOT use slacker permissions.

File permissions for “cca_qc_geoip_plugin.php”: Old versions of the CC plugin (pre 0.6.2) were over zealous, and on first creating the add-on set permissions to 644. On a dedicated server this may prevent later changes to the add-on; to resolve this problem delete the add-on or change its permissions to 664. The current versions of the plug-in should correctly determine what file permissions to set.

Discrepancies: Remember your country geo-location data may be out of date (new IP addresses ranges are still being allocated to countries). If you and all your plugins use Cloudflare then they will all identify the IP address to the same country or the same unknown. However, if your plugins use other Geolocation then there is a chance of discrepancies (one system may be using more up to date data than the other). A comment on the CC for WP Supercache post found this resulted in the “wrong cached country” on one in a thousand visits.

If this is unacceptable then you can tell Country Caching to use the same look-up used by your geolocation plugin. Note: the Country Caching extension and Category Country Aware (CCA) plugin share the same Geolocation and will always be synchronized.

6. Auto & Manual Uninstall

You should deactivate (removes the add-on script) and then delete the plugin in the normal manner. Then clear the Comet Cache cache (Dashboard->QuickCache->Clear)

However, just like with Comet Cache there may be occasions when the normal method fails to completely uninstall.

If all else fails:

  1. Log into your site via FTP; e.g. with CoreFTP or FileZilla.
  2. Delete this directory and contents: /wp-content/plugins/country-caching-zen/
  3. Delete this file: /wp-content/ac-plugins/cca_qc_geoip_plugin.php
  4. Then, via your WordPress Admin: Dashboard->QuickCache->Clear

7. Warning:

You should not use ANY Caching plugin OR extensions to them UNLESS you know how to use an FTP program (e.g. Filezilla). Caching plugins can cause “white screen” problems for some users; and sometimes the only solution is to manually delete files using FTP or OS command line. Comet/Quick/Zen cache is no different; when I checked the first page of its support forum it included 3 posts about this. The Country Caching plugin deletes files on deactivation/delete, but in “white screen” situations you may have to resort to “manual” deletion – see FAQ for instructions.


  1. stingerpk


    I am using this plugin on one of my sites with zencache pro. The file permissions are alright and the addon file is in place. However, the plugin seems to be doing nothing. Separate caches are not served and there is no additional comment in zencache comments in page source.
    Any idea what the problem may be?

    • AW

      Hi stingerpk,

      It’s working for me with the latest WP (4.3.1), Zen (150930), and CC extension (0.8.0). I’ve emailed you for more info.

Leave a Reply

Your comment will appear after its approved; usually within 12 hours but can be up to a week.
Email is optional and never published. It will only be used to contact you if clarification of your comment is needed.

Copyright © 2015-2024 Webstuff.Inblighty.Com
This site recommends and is hosted by: Kualo Web Hosting.    
Theme: hemingway

Blog home  |  ↑ Top of Page ↑