Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Adding support for etags in $.ajax() - and simplified the if-modified…
…-since implementation. Thanks to Lawrence for the patch! Closes ticket #4764.
- Loading branch information
Showing
4 changed files
with
101 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
error_reporting(0); | ||
|
||
$ts = $_REQUEST['ts']; | ||
$etag = md5($ts); | ||
|
||
$ifNoneMatch = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false; | ||
if ($ifNoneMatch == $etag) { | ||
header('HTTP/1.0 304 Not Modified'); | ||
die; // stop processing | ||
} | ||
|
||
header("Etag: " . $etag); | ||
echo "OK: " . $etag; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
error_reporting(0); | ||
|
||
$ts = $_REQUEST['ts']; | ||
|
||
$ifModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false; | ||
if ($ifModifiedSince == $ts) { | ||
header('HTTP/1.0 304 Not Modified'); | ||
die; // stop processing | ||
} | ||
|
||
header("Last-Modified: " . $ts); | ||
echo "OK: " . $ts; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters