Resource Cache

Web content

restdb.io lets you control both client cache and server cache using the global settings. In the Settings tab (while in development mode) you can enter a JSON configuration for how the server and clients should cache your Page content.

For example, to cache all Javascript and CSS on the client, and cache a specific Page on both client and server:

{
…
  "restdb": {
    "cache": [
      {
        "content-type": "text/css",
        "client-max-age": 86400
      },
      {
        "content-type": "text/javascript",
        "client-max-age": 86400
      },
      {
        "match": "index\.html",
        "server-max-age": 60,
        "client-max-age": 3600
      }
    ]
  }
    …
}
  • "content-type" - exact match of Page content type
  • "match" - a regular expression that matches your Page name
  • "client-max-age" - client cache in seconds
  • "server-max-age" - server cache in seconds

Media archive resorces are cached on web clients automatically in 24 hrs.

REST API calls

Caching of REST queries are supported using the cache-control HTTP header field. The data from queries are cached on the server. Cache hits does not renew cache timeout.

To cache a query in 10 seconds:

curl -i -H "Accept: application/json"\
     -H "cache-control: max-age=10"\
     -H "Content-Type: application/json"\
     -H "x-apikey: 560bd47058e7ab1b2648f4e7"\
     -X GET "https://rdb-simpledb.restdb.io/rest/product"

Skip the cache for a query:

curl -i -H "Accept: application/json"\
     -H "cache-control: no-cache"\
     -H "Content-Type: application/json"\
     -H "x-apikey: 560bd47058e7ab1b2648f4e7"\
     -X GET "https://rdb-simpledb.restdb.io/rest/product"