ETag & Last-modified headers in dymanic pages

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
yurik
Forum Newbie
Posts: 7
Joined: Tue Feb 12, 2008 3:52 pm
Location: Oushuu, Japan

ETag & Last-modified headers in dymanic pages

Post by yurik »

All my site's pages are parsed by PHP. This means that none of these headers are generated by default.

My pages have currency amounts which do not necessarily change every day. Currency rates change every day but my currency amounts may not change every day.

Example:
2500 yens = 24.35USD @ 102.69 yens/usd (My site would show $24 because I round the result)
2500 yens = 24.26USD @ 103.05 yens/usd (My site would show $24 because I round the result)

So this means that my site's dollars would only change when there is at least a $1 change in exchange rate.

Is there any way to make ETags and Last-modified tags ? Are they really necessary for SEO positioning?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: ETag & Last-modified headers in dymanic pages

Post by Chris Corbyn »

I'm not sure about search engines but there intended purpose is to save bandwidth by not serving the same content twice.

The E-Tag can be anything which uniquely identifies a revision of the data. Ideally it would be something like a MD5 but realistically that's a bit wasteful and expensive. It's probably best to just serve the E-Tag as the Last-Modified time formatted a little differently. It would be a weak E-Tag but for the purpose of what you're doing it should work.

If you know the exchange rate only changes daily, just serve new E-Tags and Last-Modified times once per day.
yurik
Forum Newbie
Posts: 7
Joined: Tue Feb 12, 2008 3:52 pm
Location: Oushuu, Japan

Re: ETag & Last-modified headers in dymanic pages

Post by yurik »

Ok, but as in my example, the exchange rate may not vary enough so as to change the dollar amount I use in my site. So the dollar amount will not change every day.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: ETag & Last-modified headers in dymanic pages

Post by Chris Corbyn »

So track it in a database. If it's changed enough, then send new last-modified and e-tag headers :) Provided you always know what the previous exchange rate was then this should be fine. Does you code currently know how much it has changed?
yurik
Forum Newbie
Posts: 7
Joined: Tue Feb 12, 2008 3:52 pm
Location: Oushuu, Japan

Re: ETag & Last-modified headers in dynamic pages

Post by yurik »

That's a good idea, thanks! :wink:
Post Reply