Enables caching for all page content (through PageController).
In your extensions yml file include
#Enable Caching on dev mode
---
Name: 'app_httpconfig'
After: '#httpconfig-dev'
Only:
environment: dev
---
SilverStripe\Control\Middleware\HTTPCacheControlMiddleware:
defaultState: 'disabled'
defaultForcingLevel: 0
#Module config
---
Name: appcache
After: '#cwpcoreconfig'
---
Page:
http_cache_force: false
extensions:
- DNADesign\HTTPCacheControl\PageExtension
PageController:
extensions:
- DNADesign\HTTPCacheControl\ControllerExtension
USE AT YOUR OWN RISK
You can force caching by setting http_cache_force
to true, that will force cache all over the website IGNORING any default SS behaviours.
You can disable cache on a page or pages with specific elements as below.
Page will have cache disabled
namespace\for\Page:
http_cache_disable: true
Any page with Element will have cache disabled
namespace\for\Element:
http_cache_disable: true
You can test your header directly in your browser's devTools or in your terminal with the following command
curl --silent --dump-header - --write-out 'Total (secs): %{time_total}' http://yoursite.com --output /dev/null
For more info refer to Silverstripe HTTP Cache Headers docs