Used in conjunction with the Slim application’s etag() or lastModified() methods, the expires() method sets anExpires header on the HTTP response informing the HTTP client when its client-side cache for the currentresource should be considered stale. The HTTP client will continue serving from its client-side cache until theexpiration date is reached, at which time the HTTP client will send a conditional GET request to the Slim application.

    The expires() method accepts one argument: an integer UNIX timestamp, or a string to be parsed with strtotime().

    1. <?php
    2. $app->get('/foo', function () use ($app) {
    3. $app->etag('unique-resource-id');
    4. $app->expires('+1 week');
    5. echo "This will be cached client-side for one week";
    6. });