Search code examples
phpcachingcache-control

PHP - Difference between session_cache_limiter() and headers?


I was wondering, if there is any difference between them:

session_cache_limiter('nocache');

and headers:

header("Cache-Control:no-store,no-cache,must-revalidate,max-age=0");
header("Cache-Control:post-check=0,pre-check=0",false);
header("Pragma:no-cache");

Assuming that I don't want any cache.


Solution

  • For all who wandered here from google search and feel lost ...

    Call session_cache_limiter before session_start if you use session.

    Send headers directly, if you don't use session, because session_cache_limiter only works in combination with session_start.