Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-02-16 18:38:27

jodeci
Member
From: Taipei
Registered: 2008-01-13
Posts: 38
Website

rand() question

Hi, I’m having a weird problem, weird as in inconsistent behavior.

I use this piece of code on my default page:

<txp:article_custom section="photo" limit="6" sort="rand()" />

You can see the result here.

TXP pulls the random articles all right, but what bothers me is, when I reload the browser, I see the same thumbnails. I am aware of the “Send “Last-Modified” header? == no” solution, but this is exactly why this is weird to me… let me rephrase the situation: on the same computer, reloading affects the random articles in Internet Explorer but not in Firefox. With another computer on a different network, reloading affects both browsers. And “Send “Last-Modified” header?” was never modified and kept to the default “yes” all the time.

Now, I am unsure which is the expected behavior of rand() in this usage, although I would prefer that the random articles change on reloading, as they do so now in 75% of my experience. Both my Firefox installs have identical settings and add ons. I have no idea why it is working in one computer but not in the other. I also have no idea why it works on one browser but not the other with the same network settings. This is just a minor problem, but the confusion is still there. Any suggestions? Thanks :)

Offline

#2 2008-02-16 19:44:17

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rand() question

It’s because of caching. Browser will only request new page if header is changed, and if you use Last-Modified Header, it caches pages untill your site gets new content. Only solution for that is setting “Set send Last-Modified header?” to No (or by writing plugin that changes last-modified header if it spots list-tag with rand()-value – but it would definetly slow your site down a lot – one of a stupid plugin).

Why then IE show the wrong content and not the first loaded content: because IE is s.h.i.t and it just doesn’t know how to cache pages according to the headers. So thats is why your browser doesn’t reload the random again – caching. If you disable it, the issue goes away. When it’s on, no can do with out resending last-modified headers.

Last edited by Gocom (2008-02-16 19:47:16)

Offline

#3 2008-02-16 20:20:11

jodeci
Member
From: Taipei
Registered: 2008-01-13
Posts: 38
Website

Re: rand() question

We all know IE is s.h.i.t. and please allow me to emphasize once more that I am aware of the cache and header issue. My confusion is with Firefox here.

With the same TXP settings, reloading changes the random result on one install yet does not change on another. Both Firefox installations have identical settings. If it’s all about the header, shouldn’t they act the same way? Well the fact is they don’t, and this is where it doesn’t make sense… if I’m making any sense at all.

Offline

#4 2008-02-16 23:25:02

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

Re: rand() question

There are some Firefox extensions that allow you to monitor both request and response headers. That should solve the riddle.

Offline

Board footer

Powered by FluxBB