I try to understand for a long time how it works.
Browser Chrome. Apache.
I create js and php code and it doesn`t work.
As I understood, firt - send request with js to php, second- php add etag to header, third - after refresh js send in header If-None-Match
JS(JQuery):
$.ajax({
async:false,
type: "POST",
ifModified: true,
url: 'trackETAG.php',
withCredentials:true,
data: { track: true},
success: function (data){
newData = data;
},
complete: function(XMLHttpRequest, textStatus){
var eTag = XMLHttpRequest.getAllResponseHeaders();
var newEtag = eTag;
}
});
PHP:
<?php
if(!empty(isset($_POST["track"]))){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Etag, If-None-Match");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Etag: 123");
$temp = null;
$zte = null;
$temp = trim($_SERVER['HTTP_IF_NONE_MATCH']);
$zte = $temp;
}
?>
HTTP_IF_NONE_MATCH always empty.
![Example](https://i.stack.imgur.com/ai544.png)
Somebody can help me?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…