[ Video Sharing CMS v4 ] html caching

Started by dtiberio,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dtiberioTopic starter

I am not sure how you are doing your page generation, but it is obvious that the html is not being cached. its fine for a low traffic site, but once it becomes popular you will have to cache html pages.

for example, you have this sidebar nav bloc which starts like this:
<div class="sidebar-nav blc"><div class="head"><h4>Video Channels</h4></div>

if you get 50,000 hits per day, unless the admin adds or deletes channels, this html will always be the same. so it is better to store the nav block as an html file on the hard drive, and then reload it from the hard drive the next time you need it, as long as it isn't more than a certain age such as 24 hours or 15 minutes or whatever.

so you do this:

if (html file exists in disk cache and age < 30 minutes)
load and use html file from disk (use a key to determine which filename it is)

else
generate HTML as usual from database query
save a copy to the disk cache (using key specified in load routine)

with 2 simple changes (load the disk cache and save the disk cache) you increase page loading performance, page generation, and decrease db usage considerably.

then you have to do this with all of the HTML content on the site that is generate from database queries, including search results for popular searches.

right now the site is slow at times and this will help fix the problem.
  •  

dtiberioTopic starter

here is an example of how to do it in PHP (I use a different language)

http://www.catswhocode.com/blog/how-to-create-a-simple-and-efficient-php-cache

keep in mind he is doing caching of the entire page, but you can't do that because you have custom pages for each user (such as how it says Admin at the header of the page)

so you can only cache the html portion that is shared among all users
  •  

PHPVibe A.

You can use
if(!is_user()) {cache it}

Similar topics (7)