summaryrefslogtreecommitdiff
path: root/lib/action.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-08-31 00:54:33 -0400
committerEvan Prodromou <evan@status.net>2010-09-02 22:26:20 -0400
commit388495f6b1fe5de9af7fc6a01b12da1a5c36093e (patch)
tree3215f2c799e1ed755a71c869345a09fa9e71db8b /lib/action.php
parentc8a69f433c8839280378551ac11290f1c8a2182e (diff)
use etag preferably for caching
Diffstat (limited to 'lib/action.php')
-rw-r--r--lib/action.php40
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/action.php b/lib/action.php
index 31ae49881..73d781590 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -982,32 +982,40 @@ class Action extends HTMLOutputter // lawsuit
function handle($argarray=null)
{
header('Vary: Accept-Encoding,Cookie');
+
$lm = $this->lastModified();
$etag = $this->etag();
+
if ($etag) {
header('ETag: ' . $etag);
}
+
if ($lm) {
header('Last-Modified: ' . date(DATE_RFC1123, $lm));
- if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
- $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
- $ims = strtotime($if_modified_since);
- if ($lm <= $ims) {
- $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
- $_SERVER['HTTP_IF_NONE_MATCH'] : null;
- if (!$if_none_match ||
- !$etag ||
- $this->_hasEtag($etag, $if_none_match)) {
- header('HTTP/1.1 304 Not Modified');
- // Better way to do this?
- exit(0);
- }
- }
- }
-
if ($this->isCacheable()) {
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
header( "Cache-Control: private, must-revalidate, max-age=0" );
+ header( "Pragma: underwear-catapult");
+ }
+ }
+
+ if ($etag) {
+ $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
+ $_SERVER['HTTP_IF_NONE_MATCH'] : null;
+ if ($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
+ header('HTTP/1.1 304 Not Modified');
+ // Better way to do this?
+ exit(0);
+ }
+ }
+
+ if ($lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
+ $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
+ $ims = strtotime($if_modified_since);
+ if ($lm <= $ims) {
+ header('HTTP/1.1 304 Not Modified');
+ // Better way to do this?
+ exit(0);
}
}
}