Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I implement a HTML cache for a PHP site?

Tags:

html

php

caching

What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'.

I know there is WP-Cache for WordPress, but I'm writing a custom solution that isn't built on WP. I'm interested in either writing my own cache (if it's simple enough), or you could point me to a nice, light framework. I don't know much Apache though, so if it was a PHP framework then it would be a better fit.

Thanks.

like image 683
different Avatar asked Sep 10 '08 20:09

different


People also ask

Can PHP files be cached?

PHP is a programming language used to create dynamic contact on a web page, like show a list of data records from a database, retrieve advertising, or show a news feed or Twitter stream. A way to speed up all of that is to use PHP caching.

How do you implement cache on a website?

Cache Enabler Simply turn it on and allow the plugin to generate static HTML versions of your web pages. In addition, you can minify HTML and CSS and you can also convert images to WebP when possible (all methods that help to speed up WordPress sites).


1 Answers

You can use output buffering to selectively save parts of your output (those you want to cache) and display them to the next user if it hasn't been long enough. This way you're still rendering other parts of the page on-the-fly (e.g., customizable boxes, personal information).

like image 93
Pedro Avatar answered Sep 27 '22 19:09

Pedro