I have a PHP 5.1.0 website (actually it's 5.2.9 but it must also run on 5.1.0+).
Pages are generated dynamically but many of them are mostly static. By static I mean the content don't change but the "template" around the content can change over time.
I know they are several cache systems and PHP frameworks already out there, but my host don't have APC or Memcached installed and I'm not using any framework for this particular project.
I want the pages to be cached (I think by default PHP "disallow" cache). So far I'm using:
session_cache_limiter('private'); //Aim at 'public'
session_cache_expire(180);
header("Content-type: $documentMimeType; charset=$documentCharset");
header('Vary: Accept');
header("Content-language: $currentLanguage");
I read many tutorials but I can't find something simple (I know cache is something complex, but I only need some basic stuff).
What are "must" have headers to send to help caching?
You might want to use
private_no_expire
instead ofprivate
, but set a long expiration for content you know is not going to change and make sure you processif-modified-since
andif-none-match
requests similar to Emil's post.Where
$etag
could be a checksum based on the content or the user ID, language, and timestamp, e.g.