Skip to content

Commit

Permalink
Revert "NEW Add better HTTP cache-control manipulation (silverstripe#…
Browse files Browse the repository at this point in the history
…8086)"

This reverts commit 2b49540.

Conflicts:
	_config/config.yml
	docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md
	docs/en/04_Changelogs/3.7.0.md
	tests/control/HTTPTest.php
  • Loading branch information
onebytegone committed Apr 12, 2019
1 parent d52558e commit 2f6f669
Show file tree
Hide file tree
Showing 20 changed files with 159 additions and 1,296 deletions.
12 changes: 3 additions & 9 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ MySQLDatabase:
collation: utf8_general_ci
HTTP:
cache_control:
no-cache: "true"
no-store: "true"
max-age: 0
must-revalidate: "true"
vary: "X-Forwarded-Protocol"
no-transform: "true"
vary: "Cookie, X-Forwarded-Protocol, User-Agent, Accept"
LeftAndMain:
dependencies:
versionProvider: %$SilverStripeVersionProvider
SilverStripeVersionProvider:
modules:
silverstripe/framework: Framework
---
Only:
environment: dev
---
HTTP:
disable_http_cache: true
5 changes: 4 additions & 1 deletion api/RSSFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ public function outputToBrowser() {
HTTP::register_etag($this->etag);
}

$response->addHeader("Content-Type", "application/rss+xml; charset=utf-8");
if(!headers_sent()) {
HTTP::add_cache_headers();
$response->addHeader("Content-Type", "application/rss+xml; charset=utf-8");
}

Config::inst()->update('SSViewer', 'source_file_comments', $prevState);

Expand Down
5 changes: 4 additions & 1 deletion control/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
$response->setBody($body);
}


ContentNegotiator::process($response);
HTTP::add_cache_headers($response);

$this->popCurrent();
return $response;
}
Expand Down Expand Up @@ -499,7 +502,7 @@ public function redirect($url, $code=302) {
*/
public function redirectBack() {
// Don't cache the redirect back ever
HTTPCacheControl::singleton()->disableCache(true);
HTTP::set_cache_age(0);

$url = null;

Expand Down
9 changes: 1 addition & 8 deletions control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,7 @@ protected static function handleRequest(SS_HTTPRequest $request, Session $sessio
} catch(SS_HTTPResponse_Exception $responseException) {
$result = $responseException->getResponse();
}
// Ensure cache headers are added
if ($result instanceof SS_HTTPResponse) {
HTTP::add_cache_headers($result);
return $result;
}
if(!is_object($result)) {
return $result;
}
if(!is_object($result) || $result instanceof SS_HTTPResponse) return $result;

user_error("Bad result from url " . $request->getURL() . " handled by " .
get_class($controllerObj)." controller: ".get_class($result), E_USER_WARNING);
Expand Down
3 changes: 0 additions & 3 deletions control/FlushRequestFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public function preRequest(SS_HTTPRequest $request, Session $session, DataModel
}

public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
if(array_key_exists('flush', $request->getVars())) {
HTTPCacheControl::singleton()->disableCache(true);
}
return true;
}

Expand Down
Loading

0 comments on commit 2f6f669

Please sign in to comment.