Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-11-23 23:27:43

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Selective cache control

I’ve got some pages that show dynamic content retrieved from feeds and I’m seeing that updates are sometimes not being displayed.

I’m guessing that this is because the browser is displaying a cached version of the page, and that this is because TXP’s lastmod timestamp has not changed (due to the fact that there’ve been no changes in the database).

There seems to be a couple of workarounds, neither of which are ideal:

  1. set Send “Last-Modified” header? to “no” – this would effectively switch off caching for all pages, resulting in increase bandwidth usage, load times etc.
  2. use update_lastmod() on these pages – somewhat misleading, as nothing in the database has actually changed

I know this has been discussed before but is there a nice way of selectively (on a per page/section basis) getting the browser to discard it’s cached version & reload the page?

Offline

#2 2014-11-24 09:02:59

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Selective cache control

You can try

<txp:mg_setheader name="Last-Modified"
	value='<txp:php>echo safe_strftime('rfc822', time(), 1);</txp:php>' />

or some other no-cache header in the concerned article forms.

Offline

#3 2014-11-24 22:24:51

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Selective cache control

Thanks etc, I’ll give it a go.

Offline

#4 2014-11-25 13:58:10

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Selective cache control

On the second thought, you should have more success with

<txp:mg_setheader name="Cache-Control"
	value="no-store, no-cache, must-revalidate, post-check=0, pre-check=0" />

Offline

Board footer

Powered by FluxBB