Hi,

As Michael correctly pointed out earlier today, I had said that I  
would write an email about caching. So, here goes:

At the moment we send, in the HTTP headers, "Cache-Control: no-store,  
no-cache, must-revalidate, post-check=0, pre-check=0". This means on  
every request we need to, through PHP, create the page over again.  
While with a single user requesting a page this seems sensible enough  
to make sure they don't miss out any new posts/comments, it doesn't  
scale well. On high traffic sites, it is desirable to run something  
like Apache's mod_cache which caches the output, and keeps it for as  
long as the Cache-Control headers allow, or a predefined maximum,  
whichever comes first. This has the advantage of, with it set to cache  
for one minute, for example, each page only has to go through PHP/DB  
once per minute, which can inevitably make a _large_ difference in  
performance.

Now, the problem is how we avoid these cache control headers being  
sent. We don't actually send these ourselves, but they are actually  
sent by PHP's session extension upon calling session_start() (there  
are config options, session.cache_limiter and session.cache_expire,  
that alter what is sent). What we want to do is allow pages to be  
cached for a certain time (maybe 30 minutes, maybe less?) for non- 
authenticated users, and forbid caching for logged in users. As what  
gets returned for certain URLs varies upon the Cookie sent, we need to  
vary on the Cookie header. (We actually need this already, but because  
caching is not allowed, this isn't ever a problem.) If we vary on the  
Cookie header, we need all anon users to send the same Cookie header,  
to which the obvious solution, I think, is to not send cookies to anon  
users.

I couldn't, in the brief time I looked, manage to implement this. This  
is going to be needed for us to really be usable on really high  
traffic sites where caching is an absolute necessity (caching at an  
Apache level can, in my testing, provide around a 300 times increase  
in the number of requests served per second).


--
Geoffrey Sneddon
<http://gsnedders.com/>


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/habari-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to