Hire Me!
Hire me for quality PHP, Python (Pylons), MySQL, Sqlite3, CSS, (X)HTML, Python and more coding projects. I have great feedback, you can look at my code on this site. I am fast and my code lasts. Currently No Openings for Coding Projects
If you have marketing, SEO or coding questions or concerns I also do some consulting. I only take clients that I think I can give a plenty of actionable steps to. Feedback has been really good. Send me a link to your site and info about your marketing strategy thus far and I will see if we are a good fit.
Hit me up on Skype: thrilling_victory
Premium Scripts
Working up to the Re-launch of CCenter. All current users will get a free upgrade!-
Recent Posts
- How to Make One Thousand Two Hundred Ninety Seven Dollars and Thirty Six Cents with DFHU
- How to Find High Quality and Affordable Programmers.
- When Should You Use a Web Framework Such as CakePHP, Pylons, etc…?
- Five More Free High PageRank/TrustRank DoFollow Links
- Catch More Juice With Link Circumcision
- The Ultimate Real Official Cheatsheet for Running Your User Generated Content Site.
- DFHU Quick Tip: Fighting Spam With User Exeperience Metrics
- DFHU Quick Tip: Save the Juice for Periodic Content
- A Mind For Converting Readers To Organic Linkers
- DFHU Quick Tip: Teaching Your Affiliates Through Keyword Bounty Hunting
- Trading Books and Stamps for Sophisticated, High-Yield Customers.
- Boiled Alive: Beating the Addition to Distraction, Confusion and Lack of Motivation.
- dfhuTip: Five Free High PR, High Trust Rank, DoFollow Links
- Kissing the Anvil for Four and Sixty Six Hours a Week
- (ab)using Apache’s `ab` Command to “multi-thread” PHP Files
I’m On Twitter
Pages
Categories
Archives
-
Thanks Commenters!
- Jerrold Gastelo on RSS Generator For Importing to Wordpress
- Raleigh Pest Control on Boiled Alive: Beating the Addition to Distraction, Confusion and Lack of Motivation.
- Victory on How to Find High Quality and Affordable Programmers.
- Nick on How to Find High Quality and Affordable Programmers.
- Underfloor Heating on When Should You Use a Web Framework Such as CakePHP, Pylons, etc…?
- Victory on The Ultimate Real Official Cheatsheet for Running Your User Generated Content Site.
- Josh-SEO Consultant on The Ultimate Real Official Cheatsheet for Running Your User Generated Content Site.
- Karl Foxley on The Ultimate Real Official Cheatsheet for Running Your User Generated Content Site.
Simple PHP Cacheing With Mixed Static and Dynamic Content
One way to speed up your development time and website is to use cache in PHP. The method I use is made to respect Rapid CAAR Development. It doesn’t require any external libraries and will work on the vast majority of web hosts (even the really cheap ones).
Download PHP Caching
PHP cache can greatly reduce server load and let you get those few thousand extra page views out of your web host, with only adding few a few lines of code to your source.
Useing The PHP Cache
For this to work you need to have a file called
cache/which is in the same directory as theincludes/directory. Thecache/folder must be read and writable by use that Apache is running as.The directory
Its pretty straight forward to use really. Just include the file and make sure
cache/is readable.To clear cache you visit
http://yoursite.faux/?clear_cache=clearyou can set the “password” in theincludes/conf.inc.phpfile. In this example the password isclear.There are other configuration options in there as well that you can use if you need them.
Now all thats left is to download the code. There are some other dirs in there as well because this is taken directly from my foundation sites creating
svnrepository.Download PHP Caching
Now on to the Code
The work horse for the cache is the output buffering
ob_*built in PHP functions. Namelyob_start(),ob_get_contents()andob_get_contents()andob_end_flush().If you are not familiar with those functions you should check out the documentation after reading over this code.
Before we get into the main code it think it will help to look at the relevant configuration file options.
DFHU Conf for Cache (includes/conf.inc.php)
And now onto the main caching functions for PHP.
DFHU PHP Cache Functions (includes/cache.inc.php)
You should use cache whenever it will reduce the amount of time you need to think about optimizations for your code, or when your code is slow or when it will save you bandwidth (for instance its perfect for sites that use ccenter).