Created HTTP Caching (markdown)

master
shoully 10 years ago
parent 05edb161e7
commit e1a5cd0c42

@ -0,0 +1,26 @@
Flight provides built-in support for HTTP level caching. If the caching condition is met,
Flight will return an HTTP `304 Not Modified` response. The next time the client requests the same resource,
they will be prompted to use their locally cached version.
## Last-Modified
You can use the `lastModified` method and pass in a UNIX timestamp to set the date and time a page was last modified.
The client will continue to use their cache until the last modified value is changed.
Flight::route('/news', function(){
Flight::lastModified(1234567890);
echo 'This content will be cached.';
});
## ETag
ETag caching is similar to Last-Modified, except you can specify any id you want for the resource:
Flight::route('/news', function(){
Flight::etag('my-unique-id');
echo 'This content will be cached.';
});
Keep in mind that calling either `lastModified` or `etag` will both set and check the cache value.
If the cache value is the same between requests, Flight will immediately send an HTTP 304 response and stop
processing.
Loading…
Cancel
Save