When you fine tune SuperCache and test its options, the special HTTP status headers generated will help you a lot. SuperCache's system serves specific HTTP headers which provide information on the current system status and if a given web resource is cached or not.
SuperCache is a caching and web acceleration system that applies basic caching techniques and approaches such as Reverse Proxy.
When a given page from the website is loaded for the first time, SuperCache will keep a cached version of the page for future use.
Cache MISS – (the requested page is not available in the cache)
(1) The web browser sends a query for the page.html web resource to the server corresponding to the requested domain, and the query reaches SuperCache.
(2) SuperCache looks for the requested page in the cache and does not find it. Such omission is called Cache MISS. SuperCache needs to access the website for the requested page.
(3) SuperCache sends a query for the page.html web resource to the source server.
(4) The source server returns the web page to SuperCache.
(5) SuperCache receives, copies the page in the cache and sends it back to the web client.
(6) The web browser receives the requested web resource.
Cache HIT – (the requested page is available in the cache)
Once the page is cached, it is directly served upon next queries without sending new requests to the origin server.
(1) The web browser sends a query for page.html to the server corresponding to the requested domain, and the query is detected by SuperCache (since the proxy server is located before the source server).
(2) SuperCache checks the cache for the requested page and finds it (Cache HIT). SuperCache serves the web page directly to the client, this time without turning to source server.
Cache check might be performed either through the Developer Tool which is available by default in the more common browsers or through a console. The special header returned from SuperCache is checked during this procedure.
Check through a Browser
There is a Developer Tool available in Firefox and Chrome through which you can check the HTTP headers exchanged by the browser and SuperCache.
To perform a check through Firefox or Chrome, load a webpage and press F12 (or Ctrl+Shift+K).
Check the HTTP headers and look for the X-SH-Cache* header in the server’s response.
Check through a Console
You can check the HTTP headers in the website’s response also through a console.
Cache tests can be performed through a remote machine.
If the machine supports curl, here is what to use:
curl -I http://cookies.goodexample.eu
cookies.goodexample.eu - replace with the website’s URL;
HTTP status headers served by SuperCache
When a webpage is loaded with SuperCache activated, the server response headers will display one of the following special HTTP headers:
This status means that cached webpage content is served. Caching is activated and running.
This status means that cached content is not served. If you are visiting a webpage for the first time, you will get this status. Upon the next page loading, the status shall be HIT. If upon every next page loading the status is MISS, this means that there is a condition, HTTP header or an HTTP cookie preventing cashing.
This status might be generated also if:
- the page is loaded for the first time;
- the website serves the Set-Cookie header which is not excluded from caching in SuperCache;
- the website serves a Cache-Control header with a directive restricting SuperCache from caching.
This status means that cached content is not served. The most common reason for this might be an excluded cookie which means that SuperCache will not serve cached content. BYPASS can be received in case a client cookie for authentication is generated that is excluded from caching. You can see these cookies below in the article.
This status aims to inform you that cached content is not loaded for the webpage since its URL is excluded from caching. You can change this under Exclude URL Addresses from Caching.
This status means that caching is deactivated in SuperCache Manager in cPanel. Cached version of the webpage is not served.
This status means that the validity of the webpage’s cached version has expired and it needs to be revalidated. Upon the next visit to the page the cached content will be refreshed and the status will change to HIT.
X-SH-Cache-Status: Whitelisted Ip
This status means that the IP address form which the query to the website is sent has been excluded from serving cached content.
This header contains the IP address from which the query to the website is send.
SuperCache supports three caching modes concerning the use of HTTP Cookies in visitors’ queries. The type of caching can be selected from the Types of Caching When Using Cookies option available under Advanced Settings in SuperCache.
To choose the suitable type of caching when using cookies you first need to test the website in details and define all cases in which it generates cookies. If there is a cookie enabling the website to provide personalized content for each user, you need to exclude this cookie from caching.
HTTP Cookies Excluded from Caching
Some of the most popular CMS such as WordPress, Joomla! and others use specific cookies to validate previous user identification. After logging into some of these systems’ administrations, users receive the following cookies:
These administrative cookies are automatically excluded from caching. Removing this defense mechanism is not supported.
When a user sends some of these cookies in the query to the website, SuperCache will return X-SH-Cache-Status: BYPASS will neither cache the website’s response, nor serve cached data to the visitor.
Administrative URLs Excluded from Caching
Just like administrative cookies, some of the administrative URLs in the most common CMS are excluded from caching.
URLs Excluded from Caching:
Unlike with cookies, the option for URLs Excluded from Caching can be deactivated. You can do this from Automatically Added URL Addresses which are Not Cached under Advanced Settings in SuperCache.
HTTP Headers Served by the Website
If a response from a website will be cached and until when the cache will be stored depends on the HTTP headers. SuperCache checks the HTTP headers in the website’s response and complies with some of them.
HTTP Set-Cookie Header
The website sends HTTP cookies to users through this header. If the website’s response contains at least one Set-Cookie header, it will not be cached by SuperCache. This option can be changed from Advanced Settings » Disable the processing of the following server headers. After you exclude this header from processing, SuperCache will not comply with it and will freely cache the website’s response.
HTTP Cache-Control Header
A number of directives from the HTTP Cache-Control Header are related to the website’s response validity and control the way caching systems will process that response. This directly influences web resource caching and thus SuperCache is sensitive towards directives from the HTTP Cache-Control Header.
HTTP Expires Header
This header specifies the time until when the response is considered up-to-date. If the response is generated later than the specified date, the response is treated by caching systems as obsolete and outdated. SuperCache might exclude the Expires header if the response contains the HTTP Cache-Control header with a max-age directive.
HTTP Vary Header
HTTP Vary header is a mechanism used by websites for notifying that content varies depending on the specifications of the users.
The header is used by caching systems so that they comply with this feature while caching content. It might use as directives other HTTP headers generated in users queries such as User-Agent, Cookies, etc.
Using Vary: User-Agent might lead to ineffective caching. If the website is serving the Vary header with a directive which is not critical for the website’s proper operation you would better exclude it from SuperCache.
If the website is serving Vary: User-Agent header, but there is no website feature or content to vary for different browsers (User-Agent) you can exclude the User-Agent directive from SuperCache.
You can exclude a specific directive of the Vary header under SuperCache settings » Ignored Vary Headers.
To test this feature through a console, you can change the User-Agent parameter in curl, e.g.:
curl -I -A "MyUserAgent" http://cookies.goodexample.eu