[wp-hackers] Staticize Reloaded... tweaks...

David Chait davebytes at comcast.net
Thu Feb 10 16:38:47 GMT 2005


In case anyone is using SR, or the plugin that was in CVS, I have two 
quickie tweaks I thought I'd share.  I got slashdotted late yesterday, which 
just crushed my shared site (looking at options for VPS or dedicated hosting 
< $75/mo now...).

The first was to echo the cache filename after the static time total, for 
debugging or hand-clearing a given cache file.
  echo "\n<!-- FILE: $staticFileName -->";

Simple. ;)

The second, more important, was that I had REAL issues with the way the 
cache WRITING code was set up.  Turns out there are few issues (at least for 
me -- not everyone might see this, but I got such super-heavy abuse of the 
caching system...):

1. The fopen call used 'a' (append) instead of 'w' (write).
2. The rest of the cache code continues blindly on after fopen fails.
3. There's no use of flock() to ensure single-access -- yes, I realize 
certain OS versions, flock doesn't do much... ;)

So, I changed a to w, wrap the entire cache processing as an else of the 
fopen test, do my 'standard' flock check/skip that I use in all my plugins 
that do caching, and moved the $buffer modifying code BEFORE the fopen 
itself so it just always occurs, and not 'inside' of the cache-to-disk step.

If people 'like' this all, I can submit it to the bug/feature db for future 
improvement.

-d 



More information about the hackers mailing list