mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX Disable caching on page previews (CMSPreviews or stage=Stage)
This commit is contained in:
parent
d7e64199a7
commit
8e3072922f
@ -8,6 +8,7 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Manifest\ModuleManifest;
|
||||
@ -139,6 +140,13 @@ class ContentController extends Controller
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// In the CMS Preview or draft contexts, we never want to cache page output.
|
||||
if ($this->getRequest()->getVar('CMSPreview') === '1'
|
||||
|| $this->getRequest()->getVar('stage') === Versioned::DRAFT
|
||||
) {
|
||||
HTTPCacheControlMiddleware::singleton()->disableCache(true);
|
||||
}
|
||||
|
||||
// If we've accessed the homepage as /home/, then we should redirect to /.
|
||||
if ($this->dataRecord instanceof SiteTree
|
||||
&& RootURLController::should_be_on_root($this->dataRecord)
|
||||
|
Loading…
Reference in New Issue
Block a user