Skip to content

What is the Branched Cache Structure

Darko Gjorgjijoski edited this page Sep 6, 2020 · 1 revision

Rapid Cache stores cache files for each page on your site based on the PROTOCOL://HOST/URI that it's caching, inside the default Rapid Cache cache directory located at wp-content/cache/rapid-cache/cache/. This builds the cache using a logical 'branched cache structure', based on the structure of the pages on your site.

To see how this works, let's assume we have a post called "Sample Post" at the following URL: http://example.com/2020/05/sample-post/. When someone visits that URL, Rapid Cache will parse out the following parts using the PHP superglobals $_SERVER['HTTPS'], $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']:

  • URL: http://example.com/2020/05/sample-post/
  • PROTOCOL: http
  • HOST: example.com
  • URI: /2020/05/sample-post/

From that information, Rapid Cache will first check if there is an existing cache file to serve for that page. If none is found, it will build the cache file path, starting with the Rapid Cache cache location (wp-content/cache/rapid-cache/cache/) and creating any necessary subdirectories to reflect the path of the URI.

In our example, the following subdirectories are created: /http/, /example-com/, /2020/, and /05/, to give us a final cache path of:

wp-content/cache/rapid-cache/cache/http/example-com/2020/05/

Note: Several special characters (such as periods) are replaced with hyphens when building the cache path, so example.com becomes example-com.)

The cache file for "Sample Post" is then written to a file called sample-post.html, where sample-post is the last portion of the URI.

We then end up with the following cache file:

wp-content/cache/rapid-cache/cache/http/example-com/2020/05/sample-post.html

Rapid Cache then loads and displays that cache file to each new visitor.

Clone this wiki locally