Zen Cart Logo
Forums / Search Engines / Show Last-Modified in http header

Show Last-Modified in http header

Views: 183

Results 1 to 11 of 11
23 Nov 2012, 10:35 AM
#1
tips007 avatar

tips007

New Zenner

Join Date:
Oct 2012
Posts:
52
Plugin Contributions:
0

Show Last-Modified in http header

i add the code:

<?php 
$file = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
header('Last-Modified: '.gmdate('D, d M Y H:i:s',filemtime($pfile)).' GMT'); 
?>

but it displays the date which i installed the zen cart

i want to show in http header the date which is same as the records "products_last_modified" in zen_products table and "last_modified" in zen_categories.
what do i make this done?

23 Nov 2012, 6:06 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Show Last-Modified in http header

What issue are you trying to solve??

27 Nov 2012, 10:55 AM
#3
tips007 avatar

tips007

New Zenner

Join Date:
Oct 2012
Posts:
52
Plugin Contributions:
0

Re: Show Last-Modified in http header

when you check a page hml header by yslow firefox, you can see the information:
Date
Last-Modified
Expires
Cache-Control
Server
...

i have the problem with "Last-Modified" attribute
i need it to show the page modified date, such as each product details page (product info display), each category page ...
but i don't know how to get this date correctly

i added the code mentioned above, but it doesn't display the last modified date of each page, it displays the zen cart installed date to each page (product pages, category pages)

27 Nov 2012, 10:58 AM
#4
tips007 avatar

tips007

New Zenner

Join Date:
Oct 2012
Posts:
52
Plugin Contributions:
0

Re: Show Last-Modified in http header

for example, if you check the page zen-cart.com/forum.php, you get

Date Tue, 27 Nov 2012 10:56:33 GMT
Server Apache
X-Powered-By PHP/5.3.2-1ubuntu4.15
Set-Cookie zcsupport_lastactivity=0; expires=Wed, 27-Nov-2013 10:56:33 GMT; path=/
Cache-Control private
Content-Encoding gzip
Vary Accept-Encoding
Keep-Alive timeout=15, max=91
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html; charset=ISO-8859-1

i want to add "Last-Modified" to this

27 Nov 2012, 4:33 PM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Show Last-Modified in http header

Again...
What issue are you trying to solve??

27 Nov 2012, 5:16 PM
#6
tips007 avatar

tips007

New Zenner

Join Date:
Oct 2012
Posts:
52
Plugin Contributions:
0

Re: Show Last-Modified in http header

i added the code to header_php.php

$file = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
header('Last-Modified: '.gmdate('D, d M Y H:i:s',filemtime($pfile)).' GMT');

when i check the html header of one product page, i got
"Last-Modified: Sat, 03 Nov 2012 11:23:09 GMT"

in fact, this product was modified on 12nd Nov, so the date should been shown "Last-Modified: Mon, 12 Nov 2012 11:23:09 GMT"
but now it displays 03 Nov (i installed the zen cart on 3th Nov)

My question is:
what do show the correct modified date of the product page "Last-Modified: Mon, 12 Nov 2012 11:23:09 GMT" ?

27 Nov 2012, 5:24 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show Last-Modified in http header

The code you are using will always look for the last time index.php was modified, which is meaningless for your purpose. Even if you made it to look for the modified date of the main_page= file, that would still not help. You would need to do some database lookup instead of this kind of code.

The big question remains, why do you feel you need to do this in the first place? What problem are you actually having, beside not seeing a date?

27 Nov 2012, 5:40 PM
#8
tips007 avatar

tips007

New Zenner

Join Date:
Oct 2012
Posts:
52
Plugin Contributions:
0

Re: Show Last-Modified in http header

gjh42:

The code you are using will always look for the last time index.php was modified, which is meaningless for your purpose. Even if you made it to look for the modified date of the main_page= file, that would still not help. You would need to do some database lookup instead of this kind of code.

The big question remains, why do you feel you need to do this in the first place? What problem are you actually having, beside not seeing a date?

cause i want to tell the robots the last modified date of each product and category
it seems it's not easy to do this

27 Nov 2012, 7:37 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show Last-Modified in http header

cause i want to tell the robots the last modified date of each product and categoryObviously.
So how and how much will it help your website to tell robots this? That is the question we are trying to get at.

You will need to write some PHP/mySQL database queries depending on the product/category that is current, and insert the result into your code. Not a huge deal, but how much effort is it worth to you to get this done? Will you get enough bang for your buck?

27 Nov 2012, 9:09 PM
#10
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Show Last-Modified in http header

i want to tell the robots the last modified date of each product and category
it seems it's not easy to do this
Not the way you are attempting to do so
Pages are constructed upon request from php and are not existent as a page that has been modified

28 Nov 2012, 12:32 PM
#11
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,278
Plugin Contributions:
37

Re: Show Last-Modified in http header

The best way is to provide last modified in your sitemap.

~Melanie