header('Pragma: no-cache');
$ pchanged = 0;
if ($ topic_id <1)
{
if ($ forum_id> 0)
{
$ sql = 'SELECT forum_last_post_time
FROM '. FORUMS_TABLE. '
WHERE forum_id = '. $ Forum_id;
$ result = $ db-> sql_query_limit ($ sql, 1, 0, 600);
$ pchanged = $ db-> sql_fetchfield ('forum_last_post_time');
$ db-> sql_freeresult ($ result);
} else
{
$ sql = 'SELECT MAX (forum_last_post_time) as forum_last_post_time
FROM '. FORUMS_TABLE;
$ result = $ db-> sql_query_limit ($ sql, 1, 0, 600);
$ pchanged = $ db-> sql_fetchfield ('forum_last_post_time');
$ db-> sql_freeresult ($ result);
}
} else
{
$ sql = 'SELECT topic_last_post_time
FROM '. TOPICS_TABLE. '
WHERE forum_id = '. $ Forum_id. 'and topic_id ='. $ topic_id;
$ result = $ db-> sql_query_limit ($ sql, 1, 0, 600);
$ pchanged = $ db-> sql_fetchfield ('topic_last_post_time');
$ db-> sql_freeresult ($ result);
}
')
$ if_modified_since = isset ($ _ SERVER ["HTTP_IF_MODIFIED_SINCE"])? preg_replace ('/;.*$/', '', $ _SERVER ["HTTP_IF_MODIFIED_SINCE"]): '';
$ gmdate_mod = gmdate ('D, d MYH: i: s', $ pchanged). 'GMT';
if ($ if_modified_since> = $ gmdate_mod) {
header ("HTTP / 1.0 304 Not Modified");
exit;
}
header ("Last-Modified: $ gmdate_mod");
Source: https://habr.com/ru/post/171873/