Home
/
Website Help
/
SuperCacher
/
SiteGround Dynamic Caching - Configuration, Headers, and Purging

SiteGround Dynamic Caching - Configuration, Headers, and Purging

Our Dynamic caching is a full-page caching mechanism powered by NGINX that’s enabled and running by default on all SiteGround servers. Applications that send the appropriate headers to allow caching will achieve unbeatable website loading speed. WordPress normally works out-of-the-box with our Dynamic Cache, but other applications may need an additional configuration.

Basic Operation

Without the dynamic caching, a user request is handled like this:

"Dynamic

After this initial request, the SiteGround Dynamic Cache will store your page content in the server’s memory and subsequent requests to the same pages will be handled directly from it as shown:

Request serviced from the cache

Default Expiration Times

The default time we keep a standard page of your site in the cache is 12 hours. This time can be overwritten by Cache-Control:max-age header sent by the application, thus the clients can manage the cache time on their end too.

Data Protection

You may be legally required, under privacy or data protection legislation to protect your website user’s personal data. So, whilst full-page caching is great and incredibly fast, there are certain cases in which it should not be used. For example, you would not want to cache a shopping cart page or a checkout page. That’s just an example but there are many similar cases like this. Usually, when a user is logged into your website or making an ecommerce transaction, the information they need to see is personalized and should not be cached. That’s why there are default exclusions from the Dynamic caching that we’ve configured.

Cookies:

We monitor whether your browser has these cookies and bypass the cache if they are present. For some, we monitor the value of the cookie while for others, just the cookie itself is enough:

wordpress_logged_in_, yith_wcwl_products, wp-postpass_, edd_items_in_cart=1, it_exchange_session_, wp_woocommerce_session, woocommerce_cart_hash, woocommerce_items_in_cart=1, Drupal.visitor.name, drupalSGCacheBypass=1, jSGCacheBypass=1, wpSGCacheBypass=1

Excluded URLs

We will match these URLs and serve them dynamically all the time based on partial or full match:

wp-login, preview=true, cart, my-account, checkout, addons, add-to-cart, wp-cron.php, xmlrpc.php, contact, task=registration, register, view=registration|administrator|remind|login, admin/content/backup_migrate/export, status.php, update.php, install.php, user, info, flag, ajax, aha

We recommend that you check that pages containing personal data will be excluded by default, by referring to the above URL matches. If you want to exclude additional URLs then refer to these instructions.

Supported Caching Headers

The SiteGround Dynamic Caching works based on headers. We have custom headers to manage it but we support all the standard Cache-control header values that all CMS apps support:

  • cache-control: no-cache – passing this header tells our system not to cache this request
  • cache-control: max-age  – this header tells our system to cache this request for X amount of seconds

Since we’re honoring the standard caching headers, your application should work fine with it out-of-the-box even without a specialized extension.

If you’re developing your own script or using a custom web application, you can exclude URLs simply by passing the appropriate header:

<php header("Cache-Control: no-cache"); ?>

Or, you can set how long your pages should be cached for:

<php header("Cache-Control: max-age=6000"); ?>

Purging the Dynamic Cache

If you’re a WordPress user, the best way is to have the Speed Optimizer plugin installed and activated. In its Cache tab, you will find a button to manually purge. In most cases, leaving the Auto Purge option should be enough. In addition to that, you can use our WP-CLI command (that comes with the plugin) to purge the Dynamic Cache:

wp sg purge

Aside from our WordPress plugin, you can manually purge the cache from the Site Tools -> Caching tab.

Testing the Dynamic Cache

As the SiteGround Dynamic Caching works based on headers, the most certain way is to make a request to your site and check the return headers. You can use the Network tab of your browser’s inspector tool, curl or an easy online tool like Online Curl (https://reqbin.com/curl) with the option to get the site’s headers. Then, check the value of our caching header:

  • x-proxy-cache: HIT – request served from the cache. Getting this means your page is successfully cached.
  • x-proxy-cache: MISS – request is served dynamically. Refresh your page and check it again. Either your cache is not turned on or that’s the first time this page has been requested for the past 12 hours. Note that enabling vary: User-Agent (or Browser Specific Cache option in Speed Optimizer) will split the cache depending on the browsers so you may need to load the page even if you’ve accessed it previously from another browser.
  • x-proxy-cache: BYPASS – request is served dynamically because the cache is instructed to skip it. Getting this means that either you’re logged in to your website, you’re testing one of the pages in our default exclude list or you have a cookie in your browser that triggers serving this page dynamically.

Share This Article