Changeset:
b16bd29d0236
https://sourceforge.net/p/mrbs/hg-code/ci/b16bd29d02365972edcdb33644bb6d6ed03f606d
Author:
Campbell Morrison <[email protected]>
Date:
Wed Mar 01 15:11:42 2017 +0000
Log message:
Made sure that caching is disabled when it should be. See SF Bugs #379.
diffstat:
web/.htaccess | 6 ++++++
web/functions.inc | 55 +++++++++++++++++++++++++++++++++----------------------
2 files changed, 39 insertions(+), 22 deletions(-)
diffs (92 lines):
diff -r a0651591b1f3 -r b16bd29d0236 web/.htaccess
--- a/web/.htaccess Sun Feb 26 07:55:57 2017 +0000
+++ b/web/.htaccess Wed Mar 01 15:11:42 2017 +0000
@@ -2,3 +2,9 @@
Order allow,deny
Deny from all
</Files>
+
+# Some web servers will use mod_expires and turn on caching for
+# pages that they think should be cached. Occasionally these cache
+# instructions will override MRBS's own cache instructions. As some
+# MRBS pages should definitely not be cached, we disable ExpiresActive.
+ExpiresActive Off
diff -r a0651591b1f3 -r b16bd29d0236 web/functions.inc
--- a/web/functions.inc Sun Feb 26 07:55:57 2017 +0000
+++ b/web/functions.inc Wed Mar 01 15:11:42 2017 +0000
@@ -119,6 +119,38 @@
}
+// Format a timestamp in RFC 1123 format, for HTTP headers
+//
+// e.g. Wed, 28 Jul 2010 12:43:58 GMT
+function rfc1123_date($timestamp)
+{
+ return gmdate("D, d M Y G:i:s \\G\\M\\T",$timestamp);
+}
+
+
+// A little helper function to send an "Expires" header. Just one
+// parameter, the number of seconds in the future to set the expiry.
+// If $seconds is <= 0, then caching is disabled.
+function expires_header($seconds)
+{
+ if ($seconds > 0)
+ {
+ // We also send a couple of extra headers as the "Expires" header alone
+ // does not always result in caching.
+ header("Expires: " . rfc1123_date(time() + $seconds));
+ header("Pragma: cache");
+ header("Cache-Control: max-age=$seconds");
+ }
+ else
+ {
+ // Make sure that caching is disabled. Setting the "Expires" header
+ // alone doesn't always turn off caching.
+ header("Pragma: no-cache"); // HTTP 1.0
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
+ }
+}
+
+
// Outputs the HTTP headers
function http_headers()
{
@@ -126,8 +158,7 @@
// We want to prevent IE8 offering "Compatability View" as that really
// messes up MRBS, especially on the Report page
header("X-UA-Compatible: IE=Edge");
- header("Pragma: no-cache"); // HTTP 1.0
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the pastt
+ expires_header(0); // no caching
}
@@ -196,26 +227,6 @@
}
-// Format a timestamp in RFC 1123 format, for HTTP headers
-//
-// e.g. Wed, 28 Jul 2010 12:43:58 GMT
-function rfc1123_date($timestamp)
-{
- return gmdate("D, d M Y G:i:s \\G\\M\\T",$timestamp);
-}
-
-
-// A little helper function to send an "Expires" header. Just one
-// parameter, the number of seconds in the future to set the expiry
-// (We also send a couple of extra headers as the "Expires" header alone
-// does not always result in caching.)
-function expires_header($seconds)
-{
- header("Expires: ".rfc1123_date(time()+$seconds));
- header("Pragma: cache");
- header("Cache-Control: max-age=$seconds");
-}
-
// Converts a duration of $dur seconds into a duration of
// $dur $units
function toTimeString(&$dur, &$units, $translate=TRUE)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits