简体   繁体   中英

Dynamic Caching of Pages

I have a website set up to check if certain channels on ustream.com and livestream.com are live or not.

The way it currently works it queries a database table of channels and then for each channel uses the API for the ustream.com or livestream.com to check if it is live or not, and does so each time someone visits the site.

The problem is that in just the first half a day of making the site live it received over 350 visits, and people keep refreshing the page so it had 15,000 hits. Which is great except that it is overloading the database.

I am thinking I need to use a cron job and create a cached page that refreshes every few minutes so that it queries the database and the API's far fewer times per hour.

Can someone give me some pointers on how to go about doing that? I know how to set up a cron job, but how do I create a cached page that is constantly being updated?

Or if you have a better solution I'd like to hear it.

This isn't a paid job, I built it as a free service to help people know which livestreamers are currently live at any particular moment.

Here is a link to the site,

http://freedomfighterstreams.com/

I am using Codeigniter MVC framework.

I would recommemd you this caching library for Codeigniter, since it's more customizable than CI's buit one:

https://github.com/philsturgeon/codeigniter-cache/blob/master/README.md

You'll find usefull examples there. Your results will be cached as a files.

(posting this as an answer, not a comment, because of the privelages)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM