The Last-Modified header speeds up the indexation of new pages at times. A blog in which there is a lot of interesting information ... Let's help with setting up Last-modified

I didn't have a sadness for me until I installed myself today SEO Scan plugin. A good plugin that shows that you may not like Google in your site and server. And my site has not liked something accurate - this is the absence of Last-Modified .


A little theory, he himself only learned about it today. Last-modified is an HTTP header that sends a signal about whether there was a change page or not, sending an IF-Modified-SINCE response with code 304. Something like this ...

Although without all this, the site will be indexed, as Yandex says, but there are substantial minuses in the absence of this title:

  • the search results will not show the date next to the pages of the site;
  • when sorting by date, the site will not be visible to users;
  • the robot will not be able to get information about whether the page of the site has been updated since the last indexing. And since the number of pages obtained by a robot from the site for one occasion is limited, the changing pages will be reinpected less often.

As you can see, there are many minuses, and first of all - it is not very smart indexation and reinpexation of the site. That is, you entered the article useful change, and I do it now much every day, and Yandex and Google can see This is just a couple of months! No, we don't need such hockey, now I will break into a cake, but this defects this shortcoming!

How to check Last-modified?

You can check in different ways, in WordPress the simplest is to establish the above plugin SEO Scan., I gave me this:

Also Barrachlit, but this is another story, then kicking and with it. You can also check last-modified through the service with the same name last-Modified.com


As you can see, and here shows the absence of an IF-Modified-Since answer - Last Modified not found! And you can use the Yandex service Check server response


Here the same thing is HTTP status code:"304 not modified" means the system does not work. Although after a while, the explicit error disappeared, but the response code 304 never appeared.

It immediately became interesting, and someone at least works? I decided to check it out for those bloggers who themselves wrote manuals on this topic:


Yes, a guy from Top on this request is found Last-modified, and therefore it is possible for me. By the way, in his article lists many ways to configure Last Modified, try them, although I found others.

How to configure Last-modified?

I will describe all the ways that I tried and immediately talk, earned me or not. But keep in mind that if I did not work, it does not mean that it does not work for you.

1. First method - installation of the plugin

The easiest way for those who have WordPress is to establish plugins, for this purpose, for example: Add Headers, If Modified Since or If Modified Since Header.

I didn't give any of these plugins, I do not know why. Can you work with you?

2. Second method - PHP code

Service last-Modified.comThe described above offers to the header.php file, at the very beginning, place such PHP code:

\u003d $ LastModified_unix) (Header ($ _ Server ["Server_protocol"]. "304 not modified"); exit;) Header ("Last-modified:". $ LastModified); ?\u003e

It also did not help me. I propose to try to place it in the index.php file at the site's root, but it did not help me.

3. Third way - V.htaccess recording

If you have a server on Apache, then most likely you will earn it. Need to file .htaccess at the root of the site insert code:

Rewriterule. * - rewriterule. * -

I did not work, since I have a bunch of NGNIX + Apache and all these manipulations s.htaccess are most often not triggered.
After all these torments, I thought: why is this me alone? I will write as hosting support, there are competent people, can you tell me? Posted, I'm waiting.

The answer came from technical support:

Everything is simple. The pages of your site are generated by PHP scripts that do not produce this title browser.
Web server (Nginx) for static files (JPG, GIF, CSS, JS, etc.) gives out the title Last-modified date of the last file change. Examples in screenshots.
If you do not have a very large site attendance, it makes no sense to cache pages on the browser side.

HTTP Last-modified header tells the client to the last page change time (object). If the client (browser, the search robot) gained a Last-modified header, then the next time you contact the address, provided that the page (object) is in the local cache, it will add a question IF-Modified-SINCE (did not change the page after the date, obtained in Last-Modified). In turn, the server, having received an IF-Modified-Since query, must verify the resulting timestamp with the last page change time and, if the page has not changed to respond 304 not modified.

Traffic savings

If the page has not changed, the server will stop sending data after sending headers with a code 304 not modified, the body of the page, image and other objects will not be transmitted.

Loading on the server

The correct implementation of the time checking of the last page change can be significantly (up to 30% or more) to reduce the load on the server. Under the correct implementation, it is implied to check the time before the start of page generation on the dynamic site. In this case, all actions to generate a page (the content request from the database, the parsing patterns, receiving comments, etc.) will not be executed. This is especially true for sites with high traffic and a long user duration. Example: The user is on the sports news website and constantly updates the main page in anticipation of the publication of the match result. In a few minutes, the page may be requested and received dozens of times. If the Last-modified header is given and the IF-Modified-Since request is processed correctly, then the page will be actually transmitted once, and 304 Not modified will be issued to all subsequent requests.

Acceleration of indexing by search engines

Search engines through a webmasters manual are recommended to send a Last-modified header and correctly process if-modified-since.

The note: The adaptive version of the site is activated, which automatically adjusts to the small size of your browser and hides some site details for reading. Happy viewing!

Hello dear blog readers We continue the topic, one of the most important SEO factors. This article will affect what can be called internal optimization subtleties, as it will be about the response code that search engines and visitors will receive in response to their appeal to the page.

The correct server response

Despite the fact that it is a rather small part when building and optimizing the site as a whole, but it is very important! Namely, it is important that the page on which there was no change from the last visit of the robot or a person gave 304 code, which means that the page remains unchanged. When the server gives the client this code, then the execution of all PHP scripts on the page does not even start, instead the page is loaded from the cache, which significantly reduces the load on the server and speeds up the page download from the user.

Thus, configuring the correct answers of our server, we kill at least five hares at least:

  • Accelerate the download page for visitors (people).
  • We reduce the load on the server.
  • In search will be (for Yandex, exactly) to display the date of the last page update, which can attract the user's attention, especially if the date is recent.
  • Site pages will participate in sorting search engines by date.
  • Significantly accelerating the site indexing by search engines!

For some reason, for me, the last item seems the most sweet (as it affects SEO and increases confidence in your site in search engines), although without a doubt the other items are also extremely important.

How to set up 304 and 200 server responses?

We have already said that in response to a request to an invisible pages, the server must give 304 Not modifiedAnd what code the server should give if the client turns to the page for the first time or refers to the changed page? In such cases, the server must give status 200 OK.. Especially this code is not necessary, if everything is in order with the page, then it always gives 200.

Therefore, we need to take care only about 304 code, since it will not send it without our intervention. To do this, we will help, as well as the title Last-modified. and request.

Headlines Last-modified.

Last-modified. - This is a header that we send using PHP, this title contains the exact time of the last page change (in seconds). This uses a generally accepted measure measurement measure: UNIX TIME STAMP.

UNIX TIME STAMP. - This is the number of seconds who have passed since the beginning of the Unix era: January 1, 1970. At the time of writing this proposal, UNIX Time Stamp is equal to 1370597447 seconds - this is 07.06.2013 09:30:47 GMT (+00: 00).

That is, everything we need to do is just send PHP title with instructions Last-modified. And the desired date:

Header ("Last-modified:" .gmdate ("d, d m y h: i: s", $ last_modified_time). "GMT");

Where Header is a design to send an HTTP header, Last-modified. - What we ship and immediately after the colon goes to:

Gmdate ("d, d m y h: i: s", $ Last_Modified_time). "GMT".

The role of the LAST-MODIFIDE value is a function gMDate ()which contains a variable invented by me $ Last_Modified_Time. (You can call anything). In a variable $ Last_Modified_Time. and contains the time of the last change in format UNIX TIME STAMP., and function gMDate () It serves to bring the date to the appropriate form (Greenwich time).

For clarity here's an example: if we are in the function gMDate () Put the value 1365003142 , then we get at the exit: WED, 03 Apr 2013 15:32:22.

Now, when we learned how the whole process occurs, the question may arise: "This is what, for each page we manually need to specify the time of the last change?" Answer: "Yes!". Personally, I do this exactly - manually, the most reliable option. However, specifically for this blog I have made everything, for example, if a new comment appears on the page, then in the variable $ Last_Modified_Time. The time of adding this comment is entered, this is done so that search engines can index new comments and knew that the site is alive. Each site is individual and you will have to come up with your own algorithm to specify the date of the last change page, or always indicate it manually.

We emphasize once again, I have the algorithm:

1) I specify the date of creation date manually, if I change something in the article (typos or finishing), then I again manually enter the new time of the last update.

2) If the visitor adds a comment, then in the variable $ Last_Modified_Time. Automatically, without my knowledge, the time of adding a comment is entered, since it is in fact this will be the date of the last page change.

What I did not consider: I have in the right column of the site fresh articles, recommended and top 10. They change constantly and at the same time for all pages. If I had changed (automatically or manually or manually automatically or manually or manually)), then the entire meaning of this action would be lost. I decided that these changes to track and take into account when specifying $ Last_Modified_Time. Not worth it, since they do not carry benefits for SEO.

As I already wrote, I can't tell you exactly how to automate the date of the last page change, but I will tell you how it does not need it!

Errors when specifying the date of the last change

The first thing that can come to the head of most people is in the header to send the last change file with the page content. Personally, my texts of the articles lie in the files, and not in the database, so that for me this method could seem to be a great way out in order not to enter each time UNIX TIME STAMP. manually. But no! Most hosting, and maybe even everything, for the date of the last change of the file, take the date of its creation, they do not take into account the subsequent changes.

I think the consequences in this case are understandable. One popular Ukrainian hosting provider (and I think it's not one) in my FAQ writes something like: "Instead of the date of the last change of file, use the function time ()which returns the current time in UNIX Time Stamp format. That's so absurd! This is just a shot! And this hosting provider is considered "one of the best," after I read it, I immediately moved to become their client.

It's just an anti-SEO, think about yourself, comes to your search page and looks: "Wow! The last time of changing the page was just that, that I guess when I come, class! ". He comes in a couple of days to the same page: "Look, I just changed again, this is a coincidence ... Wait, and why I do not see any changes? Okay, I will come to another time. " It comes again: "Well, there is no peasant, it is no longer funny, you can not trust." Here is such a fairy tale :)

And then people are surprised why the results in the search for extradition are not as I would like, but because the banal is lost to your site confidence (TRUST). Straight as in the parable "about the shepherd and wolves."

So, with the basic errors figured out: you can not specify the current time and I do not advise you to specify the change time of the file. Now continue to disassemble how it all works.

Set up sending headlocks Last-modified. It is exactly 1/3 of the case, we still have to: make an answer to the request and enable page caching. Both of these actions will not take a lot of time and lines of code.

- This is a customer request to your server, in it the client asks: "Does the page have changed from my last visit?" If the page has not changed, then we must stop performing the further page download to the team:

In this case, the body of the page should not start drawn, it all happens until the first withdrawal of something to the page! Together with this you need to return the server answer to the client. 304 Not modifiedThus, saying that the page needs to take from the cache. Let's right away:

If (ISSET ($ _ Server ["http_if_modified_since"]) && strtotime ($ _ server ["http_if_modified_since"])\u003e \u003d $ Last_Modified_Time) (Header ("HTTP / 1.1 304 Not Modified"); die;) Header ("Last-modified : ".gmdate (" D, D MYH: I: S ", $ Last_Modified_time)." GMT ");

So, in the first line, using the help of HTTP_IF_MODIFIED_SINCE with the help of our server, as well as immediately check the number of seconds in the http_if_modified_since, more than in $ Last_Modified_Time. or not? If more, then the date of the last visit of the client later, than the date of the last page change, from here we make a purely logical conclusion that the page has not changed, which means the second line send the server response 304 Not modified And 3 lines kill (stop) execution of all scenarios on the page. In other words, stop loading it.

If the client did not send us an HTTP_IF_MODified_Since request or his last visit turned out to be earlier than the date of the last page change, then we (by default) give the code 200 OK. And the fifth line we send him a relevant date of change of page, instead of what he had.

About if_modified_since and how the code arranged told you everything you need, besides what the StrTotime () function is:

STRTOTIME ($ _ Server ["http_if_modified_since"])

The attentive and seamless reader could already guess that this feature converts the usual date in UNIX Time Stamp, since the $ Last_Modified_time variable we specify it in it, and therefore for comparison we need to bring everything to the overall denominator of the overall measurement system.

And last, we can only turn on caching, this is done using the following lines:

Header ("Cache-Control: Public"); Header ("Expires:". Date ("R", Time () + 10800));

Where the number 10800 is the time (in seconds) to which we want to share the page, that is, in this example for 3 hours.

And as always, for those who do not understand anything, I spread everything completely, how it is in my blog:

\u003d $ Last_Modified_Time) (Header ("HTTP / 1.1 304 not modified"); DIE; / * killed everything below * / ) Header ("Last-modified:" .gmdate ("d, d m y h: i: s", $ last_modified_time). "GMT"); ?\u003e And I went to go all the rest of the page

I think you could see that the whole story with a last-modifide is an analogue of the tag in -. So LastMod is familiarizing and advisory, and no one will argue with the answers of your server. Naturally, not uncommon when Lastmod in the site map differs from the header of the last-modifide, but from that moment they should be the same with you! After all, now with you what science has been studied, not to like to like mountain-webmasters, which further sitmap.xml has not advanced.

Personally, at the moment I do not use the Lastmod tag in my credit sites, perhaps later I will review my actions, but so far I don't see the point of being so stormy, having the right headers Last-modified. :)

And finally, check the correctness Last-modified. And you can with this service: click.

Thank you for your attention, special thanks to the ever-growing number of subscribers, for me it is the greatest stimulus to write in the blog more often. So who has not yet subscribed to the release of new articles, welcome!

Why is this post in the CEO heading? LAST MODIFIED, as search engines assume, a very important HTTP header, which is needed to report the date of the last modification of the document, that is, the date of the last change on the page.

Correspondingly, if this header is not, more precisely, it will not be given, then the site is deprived of some advantages. In particular, that's what I read on the Network of the Last Modified Network:

  1. The rate of indexation of new pages is improved, as well as for 1 visiting the robot can pick up more pages to the index.
  2. Improves the speed of reindaying the pages that you have made changes. It is very useful, but without this header of accounting your edits you need to wait longer.

In principle, this is enough to want to check and if you need to configure this title.

How to check Last modified?

There are several tools, I liked this most - http://www.tools.seo-auditor.com.ru/if-modified-since/
Here I just just enter the address of the main page or any article, and then choose a search robot - Yandex.

Last modified on my site found, it's great. But initially it was not, how did I configure it?


How to configure Last Modified?

To be honest, nothing helped me. Maybe due to the fact that the Nginx server. I set Addheaders - this plugin puts all useful HTTP headlines and among them there is a Last Modified, but this plugin did not help me, although somewhere a year ago it successfully activated this title on my site.

Also on this blog I put the Clearfy premium plugin about which I wrote. Useful thing, there is also a function that would allow Last modified.

I activated the option, but the title did not give up according to the results of the inspection. But in the end, everything decided to appeal to those. The support of the plug-in - there I described the configuration of my server and gave me a specific advice - go to the server control panel, turn off something and that. Said - Made and now the headline is given.

I think the adding header will have a positive effect on my sites.

A universal solution - you are most likely the addheaders plugin, if you have an Apache server. If Nginx, then try to disable SSI in the domain settings and again activate this plugin.

In the field of site optimization sites (SEO), there are generally a lot of different myths. Some of them have a foundation that generally happened from where. In this note, consider one of them - using the Last-modified response header.

Some time ago, a certain document came to us entitled "Ingate Recommendations for Web Studies on Promotional Sites." And one of the "recommendations" was as follows:

After a redesign or on a new developed site, the date of the last modification of the site pages should be spelled out (Last Modified)

To add to the PHP information on the date of the last modification of pages, it is necessary to insert the script at the very beginning of the source code of each page.


Header ("Last-modified:". date ("D, D, D MN Y H: I: S", TIME ()). "GMT");
?>

It was this wild Achinea that, this unfortunate nonsense and frankly delusional code and advocated me to write this note. Here I will try to explain what Last-modified is, why it is needed and how browsers and search engines use it.

What is Last-Modified

The web server when transmitting information to the client (browsers or search robot) reports quite a few additional data. They can be viewed in the browser console, for example:

configure the server for the issuance of correct response headers (for example, if the page does not exist, issue an error 404, and if an IF-modified-since request received, then give out code 304, if the page with the date specified in the query has not changed).

You can also see that if the server does not respond to the GET conventional request, it does not differ from the usual query. That is, the Last-modified header with current time, besides and incorrectly formed (hi \u200b\u200bintegrate!) Not needed at all!

Is it necessary whether Last-modified or not?

Generally needed. But it is important to understand that the headline does not play any role, but the entire scenario of conditional requests, which should be implemented by the site to the end. It is in this case that we will get a high source of indexing site.

But often implementing it in the finished CMS is very difficult. Perhaps this will require quite significant changes in the CMS itself.

Although for a series of CMS, this can be implemented on the inclusion of pages caching. If CMS caches pages, creating and giving out actually static files, then the web server itself will be correctly responding to conditional requests. For example, in WordPress, this can be implemented using the WP Super Cache plugin:

Check it in your work. I turned on this plugin, opened the browser in an anonymous mode and made two requests for one page. It is clearly seen that the second answer is right - 304 not modified:

Instead of imprisonment

Thus, we dealt with the Last-modified header. First, it must transmit information about the date and time of the real change of document. Secondly, the server response is extremely important to the conditional request with the IF-Modified-SINCE header.

Well, listen to the sienes who do not know the elementary basics of the Internet.

Did you like the article? To share with friends: