Home
/
Website Help
/
Other
/
Last-Modified HTTP header explained

Last-Modified HTTP header explained

When a visitor browses your website, his/her browser caches your images, html, style sheet, and other files locally for better performance. If you have the so-called “Last-Modified” header set in your pages, next time when the same visitor loads your website, the server will check whether there is a change in the files since the last time they have been accessed.

If there is no change, the server will send a “304 Not Modified” reply to the browser and the information will be loaded from the local cache. If you do not update your website very often, using “Last-modified” headers can significantly increase its loading speed.

If your website is using plain HTML files, the “Last-Modified” is just the time stamp of the HTML file. If you have, however, dynamic pages that fetch data from a database for example, things are a bit more complex. The server does not know how you are generating your data or how the data can be changed from the last time it was loaded.

Therefore, you should add some code to your PHP scripts that generate the header with the proper information in it.

The exact code to use, however, depends on the application you are using. The basic idea is to generate the following text in the output of your website:

Last-modified : Mon, 21 Nov 2017 01:03:33 GMT

This header means that the information in your website has been updated exactly on this date and hour. If your visitor has already downloaded it locally, it will be displayed much faster next time he/she loads your pages.

Share This Article