Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-19 21:36:38

hcgtv
Archived Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Send Last-Modified header

Running Textpattern version: 4.0.3 (r1835)

Send Last-Modified header = Yes

Site set to Live mode.

I have a page that uses the SimplePie plugin to display 4 feeds and it doesn’t reflect the latest feeds without setting the site to Testing mode.

Offline

#2 2006-09-19 22:47:40

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Send Last-Modified header

Textpattern tells the browser to use a cached copy of pages when in Live mode, unless the lastmod date (stored in the database) has been changed since then. SimplePie doesn’t alter the lastmod date, so Textpattern keeps telling the browser to use the old one.

Possible solutions are:

1. turn off Send Last-Modified
2. have the SimplePie plugin reset the last-modified date when feeds change by calling update_lastmod()
3. have the plugin temporarily disable the send_lastmod setting on specific pages

(2) is probably the best solution if you’re displaying feeds on the majority of pages. It’ll reset caching site-wide though, which will negate the benefits of caching if you’re only displaying feeds on a small number of pages. (3) would be better in that case; but it’s not obvious how the plugin might know on which pages to disable caching — it has to decide before the page template is parsed.

FYI for developers: see update_lastmod() and handle_lastmod() in txplib_misc.php. They’re both 4.0.4+ only. handle_lastmod() is called after plugins are loaded, but before the page template is loaded and parsed. You could change the value of $GLOBALS['prefs']['send_lastmod'] to turn caching on or off for specific pages or URLs.


Alex

Offline

#3 2006-09-20 01:04:57

hcgtv
Archived Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Send Last-Modified header

I’ll use #1 for now until I can figure out what’s the best approach for the plugin. If it’s being used for one section, like I am now, then #3 would work, but if it’s used on a side menu that appears on all pages, then #2 would be best. Back to the drawing board.

Thanks.

Offline

#4 2006-11-18 21:53:17

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Send Last-Modified header

What also seems to work is to let the plugin also output a last-modified header, dated more than 7 days ago, during the page template parsing. Due to output buffering, you can still send headers, even though you’ve already begun parsing the page template. The new last-modified header overrules the previous one.

When the browser checks if the document on the server is newer than the one it has cached, TXP will notice that the last-modified date that the browser supplies is more than 7 days old and that causes it not to send a HTTP 304 response but send a newly generated page instead… again with a last-modified date more than 7 days in the past (due to the plugin), but newer than the previous last-modified date, because this page was requested at a later time.

Last edited by ruud (2006-11-18 21:53:30)

Offline

Board footer

Powered by FluxBB