Forum Moderators: phranque

Message Too Old, No Replies

Best way to cache a site?

         

CWebguy

2:25 pm on Mar 14, 2009 (gmt 0)

10+ Year Member



What would be the best way to cache a site, or even part of a site such as a sidebar or two that are dynamically created?

I've seen things like Wordpress plugins that do this automatically, at least for a full page by creating an html page that the server can dish up. Wondering if anyone had any ideas on where to start.

Thanks,
CWebguy

phranque

3:56 am on Mar 15, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



a lot depends on the technology of your server.
if you have an apache server you could use mod_cache [httpd.apache.org].

otherwise, if you are using SSI or php, for example, you could create static versions of the dynamic content with a cron script or whenever the content changes and include those static files in your template.

topr8

10:03 am on Mar 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



also PEAR cache_lite [pear.php.net]

i started to roll my own cache with a classic asp site in a very unsophisticated way but it certainly helped a lot (eg, pages got served faster, it was a shared host and less db calls made the page was visibly faster at times)

at its simplest, i set up a scheduled task (win server) to run every 24 hours, which built a static text file of the nav column (for each category and the home page)

on all pages i then included the static file as an include rather than making a db call to get the data.

... from this small step you can get as sophisticated as you like - just think in advance of a decent naming structure for the static files (which could be whole pages or just parts of pages)

i'm now on apache with php and cache_lite has all kinds of built in functionality regarding locking files while being overwritten and so on.