Using HTTP Cache

Discover our Public Cloud offer

Shared Hosting for Everyone, imagined by developers, for developers.

Discovering the Public Cloud

To speed up access to your website, you can set up the HTTP cache. Here are the steps required to do this:

1. Check that your application manages a cache

So that the cache can query the upstream to determine that the targeted resource has not been changed, the application must provide the Etag and/or Last-Modified header.

A response CANNOT be cached if:

  1. the Vary header is *,

  2. the Content-Type header is not present,

  3. the resource Content-Type is not one of the following values:

    • text/html
    • text/xml
    • application/xml
    • application/html+xml
    • application/rss+xml
    • application/rdf+xml
    • application/atom+xml
    • text/javascript ;
  4. the Cache-Control header takes one of the following values:

    • private
    • no-store
    • no-cache
    • no-transform ;
  5. the Set-Cookie header is present,

  6. the Authorization header exists, but Cache-Control takes none of the following values:

    • public
    • must-revalidate
    • proxy-revalidate
    • s-maxage ;
  7. The HTTP status code is not one of the following:

    • 200
    • 203
    • 204
    • 206
    • 300
    • 301
    • 404
    • 405
    • 410
    • 414
    • 501

2. Activate the HTTP cache

This is done in Web > Sites > Modify the site > Cache.

Add a site: HTTP cache
Add a site: HTTP cache

Using PURGE

PURGE can be executed in three different ways at alwaysdata:

  1. by using the full URL of the resource (e.g. https://test.alwaysdata.net/foo/bar). This will remove the related cache entry and its variations (generated by the Vary header);
  2. by adding the X-Cache-Purge-Match: wildcard header and adding a wildcard to your URL (e.g. https://test.alwaysdata.net/*). This will remove all entries matching the URL template;
  3. adding the X-Cache-Purge-Match: startswith header and adding a partial path to your URL (e.g. https://test.alwaysdata.net/foo). This will remove all entries matching the URL template (and thus https://test.alwaysdata.net/foo/bar).