Automatically fill the page cache

Hi,

I have my whole site cached with page cache, because each page needs some time to render. What I would like to do is to delete all files in the cache (I have no problem with that). But after I have deleted everything, I would like to cache each and every file again, so that my visitors don't experience any long load times. Any ideas on how to do this the most efficiently. It's a cache of more than 5.000 pages. Any ideas are welcome. Thanks.

Kind regards,

Nick

Hi Nick,

Nick Snels wrote:

...after I have deleted everything, I would like to cache each and every file again, so that my visitors don't experience any long load times. Any ideas on how to do this the most efficiently.

As far as I know, the only way to get a page into the cache is to pull it there with a request from a client. OTOH, the client need _not_ be a browser. You could write a script that 'computes' all the possible requests (reflecting on controller methods) and then issues them (to the server through the cache) using Ruby's net/http library. It's not elegant, and there're likely to be views that wouldn't get rendered without making your script smarter, but it might not be a bad first step.

HTH, Bill

Hi Bill,

thanks for the reply. I already tought of this solution, but this would mean hammering my own server for a while. Isn't there a more elegant way, so that the web server is not involved but that Rails handles the cache generation.

Kind regards,

Nick

Well, the web server (eg apache) wouldn't have that much load, would it? I bet 99% of the load will be in your app anyways.

In terms of traffic I would recommend a locally installed wget or curl client just pulling everything. And in terms of cpu load: you could run that script reniced(see "man nice") level, so it doesn't block incoming requests.

This way your users might have to wait a bit while the page cache slowly grows, and then you are back at hi speed.

Or else: create an identical instance on a second machine, have the cache recreated there, copy everything off that machine onto your live system.

/eno