HTTP level caching, so we can stick varnish in front of the web pages

This commit is contained in:
Shish
2011-12-27 19:23:37 +00:00
parent 9b93df4e22
commit cfbeddde9f
3 changed files with 23 additions and 2 deletions

View File

@@ -183,7 +183,7 @@ class Page {
* Display the page according to the mode and data given
*/
public function display() {
global $page;
global $page, $user;
header("Content-type: ".$this->type);
header("X-Powered-By: SCore-".SCORE_VERSION);
@@ -196,7 +196,22 @@ class Page {
switch($this->mode) {
case "page":
header("Cache-control: no-cache");
header("Vary: Cookie, Accept-Encoding");
if(CACHE_HTTP) {
if($user->is_anonymous() && $_SERVER["REQUEST_METHOD"] == "GET") {
header("Cache-control: public, max-age=600");
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 600) . ' GMT');
}
else {
#header("Cache-control: private, max-age=0");
header("Cache-control: no-cache");
header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 600) . ' GMT');
}
}
else {
header("Cache-control: no-cache");
header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 600) . ' GMT');
}
usort($this->blocks, "blockcmp");
$this->add_auto_html_headers();
$layout = new Layout();