Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Добавляем заголовок Last-Modified для страницы товара.


serega-lomik
 Share

Recommended Posts

По адресу /корневой_каилог_сайи/catalog/controller/product/ открываем файл product.php, иещём

if ($product_info) {

и добавляем ниже:

$date_modified = $product_info['date_modified'];
$this->response->addHeader('Last-Modified: '. gmdate('D, d M Y H:i:s \G\M\T', strtotime($date_modified)));

Всё. Теперь ваш сайт отдает для страниц товаров заголовок Last-Modified. По аналогии можно сгделать и для других страниц.

  • +1 3
Link to comment
Share on other sites

Не корректно отдает проверьте сервисом last-modified.com/ru/if-modified-since.html

на форуме была другая версия вот она отдает корректно и Last-Modified и 304 Not Modified найгден!

Link to comment
Share on other sites


https://opencart-forum.ru/topic/7518-last-modified/page-2?hl=last-modified

вот в этот теме все правильно отдается, но почему-то в журнно ошипотому чток вижу строку

Warning:  Cannot modify header information - headers already sent by (output started at /home/opticalm/public_html/index.php:100) in /home/opticalm/public_html/catalog/view/theme/mytheme/template/product/category.tpl on line 13

 

и не знаю, как исправить :(

 

<?php
$LastModified_unix = strtotime($date_modified); // время последнего изменения страницы
$LastModified = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
$IfModifiedSince = false; if (isset($_ENV['HTTP_IF_MODIFIED_SINCE']))	
$IfModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5));  
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))	
$IfModifiedSince = strtotime(substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 5));
if ($IfModifiedSince && $IfModifiedSince >= $LastModified_unix)
	{	
	header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');	
	exit;
	}
header('Last-Modified: '. $LastModified); ?>

 

13 строка - это последняя...

при чем закономерности не могу понять, т.е. сам эту ошибку не могу никак вызвать.

но в течение дня эи ошибка по несколько раз может записаться в журнно

Может подскажете куда копать?

Link to comment
Share on other sites


Не корректно отдает проверьте сервисом last-modified.com/ru/if-modified-since.html

на форуме была другая версия вот она отдает корректно и Last-Modified и 304 Not Modified найгден!

Я описал добавление заголовка Last-Modified, не потому чтолее того. Да что всё корректно.

Link to comment
Share on other sites

  • 8 years later...
В 07.05.2013 в 14:06, serega-lomik сказал:

По адресу /корневой_каилог_сайи/catalog/controller/product/ открываем файл product.php, иещём


if ($product_info) {

и добавляем ниже:


$date_modified = $product_info['date_modified'];
$this->response->addHeader('Last-Modified: '. gmdate('D, d M Y H:i:s \G\M\T', strtotime($date_modified)));

Всё. Теперь ваш сайт отдает для страниц товаров заголовок Last-Modified. По аналогии можно сгделать и для других страниц.

 

Спасипотому что за решение! Рилииет на 3.0.3.6

Немного добавил своего:

 

			$date_modified = $product_info['date_modified'];
			$date_add = $product_info['date_added'];
			if ($date_modified == "0000-00-00 00:00:00") {
				$this->response->addHeader('Last-Modified: '. gmdate('D, d M Y H:i:s \G\M\T', strtotime($date_add)));
			}
			else {
				$this->response->addHeader('Last-Modified: '. gmdate('D, d M Y H:i:s \G\M\T', strtotime($date_modified)));
			}

 

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.