1

The site doesn't send Last-Modified header in its response.

I know I should insert somewhere something like header("Last-Modified: " . the_modified_date()); but where?

Loops
  • 11
  • 1
  • 2
  • Before ***any*** output is made. – mario May 15 '11 at 05:58
  • This is [solved on the WordPress Stack Exchange](https://wordpress.stackexchange.com/questions/257111/setting-last-modified-http-header-on-static-home-page). – Slam Mar 08 '19 at 08:10

3 Answers3

2

The "Last Modified" WordPress plugin works for me. http://wordpress.org/extend/plugins/header-last-modified/

It requires a change in wp-includes/template-loader.php so be careful when updating the WordPress core.

Kathy
  • 21
  • 2
0

This worked for me on all posts - added into theme functions.php file:

add_action('template_redirect', 'theme_add_last_modified_header');
function theme_add_last_modified_header($headers) {
    global $post;
    if(isset($post) && isset($post->post_modified)){
        $post_mod_date=date("D, d M Y H:i:s",strtotime($post->post_modified));
        header('Last-Modified: '.$post_mod_date.' GMT');
     }
}
-2

Edit wp-config.php insert it at end of file before ?>

Danzan
  • 958
  • 5
  • 8