Page 1 of 1

Caching: When and Where?

Posted: Mon May 05, 2008 5:52 am
by lafever
Alright, I've never worked with any caching before and I'm getting ready to (so I won't have to do it later on once everything is done)

I stumbled across a couple of articles and have some questions on when and where to cache. For the time being I'm on a shared host that doesn't have APC or anything. Although I am going to recommend them installing it.

I know this will be pretty broad with what I'm asking but here is what I have in mind. Please critique my thoughts. I do believe that the API caching I have thought up will be good enough though and I think the API caching is most important right now though since it is currently slowing the load time.

API Caching
  • Twitter - Will store to a simple file containing my most recent updates (Updated every 2-3 minutes)
  • Flickr - Will store the same as Twitter containing the information for the photos (Flickr updating once or twice a day)
Seems simple enough for those. Where my concerns rise is for my blog system I want to cache the archives so it isn't running a query every single time someone views the page. What is the best way to approach this? And how should it be stored (file or database)? My thoughts at first were to file cache but the more I think about it that doesn't seem to be the best approach on it seeing as it will be creating tons of files on the server. Or is there a simplified method of doing it? I've read a couple articles on how to cache but haven't really came across any on how to approach something that I am trying to achieve.

Here are the articles I checked out:
http://www.rooftopsolutions.nl/article/107
http://www.developertutorials.com/tutor ... page1.html

Re: Caching: When and Where?

Posted: Mon May 05, 2008 11:19 am
by Christopher
I don't see anything wrong with creating "tons of files" on the server. After all ... that's what servers are for. ;) I usually have the administrative page where you edit the content clear the cache. But you can also have things like uploading do the same thing.

Re: Caching: When and Where?

Posted: Mon May 05, 2008 12:12 pm
by lafever
Right. Didn't think about the clearing the cache when it's edited part. Brings up another idea of the main page being cached but updated when a new post is made, but I'm sure that was pretty obvious.