mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Refactor redirect cache busting into middleware
This commit is contained in:
parent
92ab6b63b1
commit
6b8f63c4d5
@ -357,3 +357,7 @@ class PageController extends ContentController
|
||||
Note this is different from `Vary: Accept-Encoding`,
|
||||
which is important for compression (e.g. gzip), and usually added by
|
||||
other layers such as Apache's mod_gzip.
|
||||
* DataObject no longer automatically invokes `HTTP::register_modification_date`
|
||||
with LastModified on construction. User code should instead invoke
|
||||
`HTTPCacheControlMiddleware::singleton()->registerModificationDate()` explicitly.
|
||||
|
||||
|
@ -769,5 +769,10 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
||||
// Even if publicCache(true) is specified, errors will be uncacheable
|
||||
$this->disableCache(true);
|
||||
}
|
||||
|
||||
// Don't cache redirects
|
||||
if ($response->isRedirect()) {
|
||||
$this->disableCache(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -657,9 +657,6 @@ class RequestHandler extends ViewableData
|
||||
*/
|
||||
public function redirectBack()
|
||||
{
|
||||
// Don't cache the redirect back ever
|
||||
HTTPCacheControlMiddleware::singleton()->disableCache(true);
|
||||
|
||||
// Prefer to redirect to ?BackURL, but fall back to Referer header
|
||||
// As a last resort redirect to base url
|
||||
$url = $this->getBackURL()
|
||||
|
@ -1812,13 +1812,9 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
/**
|
||||
* Can the body of this form be cached?
|
||||
*
|
||||
* Figure out if we can cache this form
|
||||
* - forms with validation shouldn't be cached, because their error messages won't be shown
|
||||
* - forms with security tokens shouldn't be cached because security tokens expire
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeCached()
|
||||
protected function canBeCached()
|
||||
{
|
||||
if ($this->getSecurityToken()->isEnabled()) {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user