Loopia Boost – Page cache

The page cache caches PHP pages as if they were static pages. If you have pages on your website that look the same every time visitors visit them, it is unnecessary for the server to rebuild the page at each visit. Instead, this cache can send a pre-built page from previous visits, making the page’s response time extremely fast. This replaces most of the functionality of standard cache solutions, such as W3TC or “WP Super Cache” for WordPress.

How do I enable the page cache?

The page cache is disabled by default and is currently activated manually by our support. In the future, this can be controlled directly in the customer zone, but right now you need to contact support@loopia.com to activate the feature.

How long does the page cache remain?

The length of time the cache remains depends on the returning HTTP code:

  • 302 – 5 minutes
  • 200 – 1 hour
  • 301 – 1 hour
  • Other – The site is not cached

Note that these times can be adjusted from the site with HTTP header values for, for example, “X-Accel-Expires” and “Expires”.

How do I clear the page cache?

For specific subpages, the cache is most easily cleared by visiting the page and then pressing Ctrl+F5 (Cmd+R on Mac) on the keyboard to do a hard reload. Then you go past the cached page and generate a new page. If the returned page is one that can be cached, it is stored in the cache for the next request.

The cache can also be cleared by inserting “/purge/” after the domain name in the url. This can clear one specific or multiple subpages. These requests can only be made locally from the website itself, or from trusted IP addresses that support can help you enter. Here are some examples of what requests might look like:

  • http://example.com/purge/ – Clears cache for home page
  • http://example.com/purge/subpage/ – Clears cache for subpage undersidan example.com/subpage/
  • http://example.com/purge/* – Clears all cache for the website

How do I see if a page is cached?

Have a look in the HTTP headers that the page returns. The HTTP header “x-cache” indicates whether the page was delivered from the cache or not. If the “x-cache” header is missing, the page cache may not be enabled on the page. The header can have the following values:

  • HIT – The page you see is a cached page.
  • MISS – The page you see was not cached, but may have been cached during your visit.
  • STALE – The page you see is cached, but the cache time has expired and a new page will be loaded in the background.
  • BYPASS – The browser asks the server to bypass the cache and deliver a new page, for example, by pressing Ctrl+F5.

Why is my page not cached?

If the “x-cache” HTTP header is completely missing (see above), the page cache may not be enabled on the page. This needs to be activated in order to function.

Furthermore, you can see in the HTTP headers that are sent from the server to the browser if there are any named “Set-cookie”. If any of those exist, the page will not be cached.

Generally for WordPress it may be that you have a plugin installed that prevents the page from caching properly. One way to investigate this is to deactivate the extensions one has installed to see if cache starts running.

Note that some pages should not be cached, such as those where you have logged in somewhere, or ones that should display different content for different visitors. Be sure to check these pages after the cache is enabled to make sure they are not cached.

How do I use page cache in WordPress?

As long as the page cache is enabled, it should work in WordPress without having to do anything else. But we can still recommend installing the “Nginx Helper” plugin (https://wordpress.org/plugins/nginx-helper/). This plugin automatically clears the cache when updating pages/entries, which simplifies the work when you are editing your page.

There is also a button for clearing all cache for the page. For this to work, the following row must be pasted into the wp-config.php file:

define('RT_WP_NGINX_HELPER_CACHE_PATH', $_SERVER['LOOPIA_FASTCGICACHE_DIR']);
Was this article helpful?

Related Articles