Heading If-Modified-Since if PHP it is not established as a fashion
Probably, each web - programmer who is were interested keshirovaniem of webs - pages on the party of the client, knows about such headings HTTP, as "If-Modified-Since" and "If-None-Match". The given headings are sent by a browser at the reference{manipulation} to page which is present in it keshe. For the correct organization keshirovanija on the party of the client, it is necessary for server application to send heading « HTTP/1.0 304 Not Modified » and to stop data transfer in case contents of required page have not changed since that moment of time which is specified in the sent heading "If-Modified-Since".
The basic problem at realization keshirovanija on the party of the client consists in receiving contents of heading "If-Modified-Since". She is called by that, that by default specified heading is accessible from the server application only in the event that interpreter PHP is established as module Apache that happens extremely seldom on servers of the organizations offering{suggesting} services of a hosting (for safety reasons and convenience of recompilation PHP). It is necessary to notice, that keshirovanie on the party of the client salutarily influences not only loading of the web - server, but also for speed of indexation of a website by search machines. In this connection, skilled SEO-experts persistently search and recommend "correct" khostingovye the companies.
Actually, there is the universal decision of the given problem not demanding intervention in a global configuration of the web - server and working even in that case when PHP it is not established as module Apache. For application of the given method it is necessary and enough that the following conditions satisfying:
* An opportunity of a configuration through files .htaccess;
* Availability and an opportunity of use of the module mod_rewrite;
* In the server application to headings "If-Modified-Since" and "If-None-Match" it is necessary to address through a file $ _SERVER, instead of by means of functions getallheaders or apache_request_headers (these functions are accessible only in the event that PHP it is established as module Apache).
So, for realization of access to headings "If-Modified-Since" and "If-None-Match" it is necessary to place in the root of a website a file .htaccess the following maintenance{contents}:
RewriteEngine On
RewriteRule.* - [E=HTTP_IF_MODIFIED_SINCE: % {HTTP:If-Modified-Since}]
RewriteRule.* - [E=HTTP_IF_NONE_MATCH: % {HTTP:If-None-Match}]
After that, necessary headings will be accessible as $ _SERVER ['HTTP_IF_MODIFIED_SINCE'] and $ _SERVER ['HTTP_IF_NONE_MATCH']. In a case if on a website mod_rewrite it is used for formation "beautiful" URL, contents .htaccess will become:
* url rewriting
RewriteEngine On
RewriteCond % {REQUEST_FILENAME}!-f
RewriteCond % {REQUEST_FILENAME}!-d
RewriteRule ^ (. *) $ index.php [QSA]
* If-Modified-Since (if php is not installed as cgi then comment lines below)
RewriteRule.* - [E=HTTP_IF_MODIFIED_SINCE: % {HTTP:If-Modified-Since}]
RewriteRule.* - [E=HTTP_IF_NONE_MATCH: % {HTTP:If-None-Match}]
It is necessary to notice, that headings "If-Modified-Since" and "If-None-Match" are not sent by a browser if in the previous searches to the given page he did not receive heading Last-Modified in the answer of the web - server. Besides at use in the web - application of sessions with installations by default, the specified headings also will not be sent by a browser. To avoid such behaviour of a browser, it is necessary to carry out before start of session function session_cache_limiter, passing as argument parameter 'private_no_expire':
<? php
session_cache_limiter ('private_no_expire');
session_start ();
?>

|