Caching

API Cache

You may enable API level caching with the ApiCache middleware:

// app/Http/Kernel.php

protected $middlewareGroups = [
    'api' => [
        ...
        \Streams\Api\Http\Middleware\ApiCache::class,
    ],
];

Cache Control

You may control the API cache with the following headers:

Disable Cache

To force fresh results use the no-cache directive:

Cache-Control: no-cache

Allow Cache

Use the max-age directive to allow cached results for a certain amount of seconds:

Cache-Control: max-age=600

Application Cache

Streams may be cached by default at the application level according to their configuration.

Configuration

Application-level streams cache can be specified in the stream configuration:

//streams/examples.json
{
    "config": {
        "cache": {
            "enabled": true,
            "store": "default",
            "ttl": 3600
        }
    }
}

Cache Parameter

You may enable application-level cache using the cache parameter:

// GET /api/streams/examples/entries
{
    "parameters": [
        {"cache": [300]}
        {"where": ["status", "active"]}
    ]
}