FREE Simple File Based PHP Cache Function

We made this PHP cache function for speeding up websites. Take a read and see how important caching is.

This simple PHP file based caching PHP function is a really good way of caching data returned from api’s or data feeds in PHP. It’s flexible and can be used in many scenarios to speed up your web app. It’s not perfect and it’s not the best method of caching but it’s quick and easy to implement using just file based .txt files.

Just make sure you include the file and also set your cache folder to permissions for writing (CHMOD 777).


Simple Usage

Include the function.


Call the function into a variable with the appropriate parameters.

  • $key is the name of the cache, give it a unique name.
  • $call_this is the PHP function name that will return the data to be cached. Note this must return data.
  • $call_this_params is the variable we pass to $call_this.
  • $expire is the number of seconds till expiry (default 1 hour).
  • $html_comment specifies whether or not to place an html comment with cache details (default true).

$data = pk_cache($key, $call_this, $call_this_params, $expire = 3600, $html_comment = true);

Echo out the data into the HTML.

echo $data;

If you have any suggestions or questions feel free to comment about the PK Cache.

Please don’t forget to give credit where credit is due and link to Pretty Klicks.


Posted in Free Resources | Tags: , , | 1 Comment
By |
RSS Feed
Keep up to date with our latest posts.

Learn more about making the most of your website, marketing and seo. It takes two seconds to subscribe to our rss feed.
You can get in contact with us via phone or e-mail, we will get back to you very promptly.

+44 (0)131 344 4522

Join our mailing list to find out about our free giveaways and tutorials. It's free.

Copyright © 2005 - 2020 Pretty Klicks Ltd (