使用session\u cache\u limiter()和session\u cache\u expire()或多标头()的PHP

使用session\u cache\u limiter()和session\u cache\u expire()或多标头()的PHP,php,http,caching,http-1.1,Php,Http,Caching,Http 1.1,我希望我的PHP页面被缓存。要允许缓存,我使用: session_cache_limiter('private'); session_cache_expire(180); session_start(); 由于我只对这些缓存头使用会话,我是否应该删除这3行并将其替换为(我从不使用$\u会话): header('Expires:'); 标头('Cache-Control:private,max age=,pre-check='); 标题('上次修改:'); 是的,如果您使用会话的唯一原因严格来说

我希望我的PHP页面被缓存。要允许缓存,我使用:

session_cache_limiter('private');
session_cache_expire(180);
session_start();
由于我只对这些缓存头使用会话,我是否应该删除这3行并将其替换为(我从不使用$\u会话):

header('Expires:');
标头('Cache-Control:private,max age=,pre-check=');
标题('上次修改:');

是的,如果您使用会话的唯一原因严格来说只是为了发送头,那么请使用
头()

header('Expires: <some GMT date>');
header('Cache-Control: private, max-age=<some GMT date in the future>, pre-check=<some GMT date in the future>');
header('Last-Modified: <some GMT date>');