After a long history of pseudo-static exploration, we found that the following methods can be used to achieve pseudo-static SEO and reduce server pressure.
> Access the PHP page
> Last-Modified is generated based on the Content Update Time, And etag is generated based on the file name and content Update time.
> Compare the client data, such as viewing the Last-Modified of the client browser and comparing etag. If the values are the same, output 304 to stop outputting the latest data.
> If not, output the latest data as usual and return the Last-Modified and etag to the client.
/**
* Output head Last-Modified and determine whether to output 304.
*/
Protected function _ echo_last_etag ($ tmp_time ){
$ Now_url = get_absolute_url ();
$ Md5 = md5 ($ now_url. $ tmp_time );
$ Etag = '"'. $ md5 .'"';
Header ('Last-Modified: '. gmdate ('d, d m y h: I: s', $ tmp_time). 'gmt ');
Header ("ETag: $ etag ");
If (isset ($ _ SERVER ['HTTP _ IF_MODIFIED_SINCE ']) & amp; strtotime ($ _ SERVER ['HTTP _ IF_MODIFIED_SINCE']) & gt; = $ tmp_time) | (isset ($ _ SERVER ['HTTP _ IF_UNMODIFIED_SINCE ']) & amp; strtotime ($ _ SERVER ['HTTP _ IF_UNMODIFIED_SINCE']) & lt; $ tmp_time) | (isset ($ _ SERVER ['HTTP _ IF_NONE_MATCH ']) & amp; $ _ SERVER ['HTTP _ IF_NONE_MATCH '] = $ etag )){
Header ("HTTP/1.1 304 Not Modified ");
Exit (0 );
}
}
From Xiaoqiang's column