Caching
ApiAxle supports caching. The following details the flow and you can take a peek at the relevant source code if that’s more your thing.
Global cache
You can optionally set a cache time (in seconds) on a per-api basis by passing an option to the provisioning script:
./bin/new-api.coffee --global-cache=20 --end-point=graph.facebook.com facebook
This will give every endpoint of the facebook Api a global cache time of 20 seconds. You can override this with cache-control.
Cache-control
Axle supports the following pragmas of the cache-control spec:
s-maxage
Setting s-maxage will make ApiAxle cache your call for as many seconds as you pass. This overrides the global cache and can be overridden by the no-cache or proxy-revalidate pragma.
proxy-revalidate
Setting this pragma will force Axle to make the backend HTTP call before caching it again for the amount of time specified by the global cache or s-maxage.
no-cache
Don’t cache the call being made. Overrides the global cache and s-maxage.
What’s cached?
- The HTTP status code.
- The
content-typeheader. - The body of the call.
For which verbs?
Only GETs are cached (probably HEADs in the future).