开发者

Http headers to cache a dynamic page

I have a classic html page generated with PHP.

For this page (served from a same URL) we have 2 cases:

  1. The user is logged (cookie based) => the page is specific to the user (we display a box with user name + personal information.)
  2. The user is not logged in => the page is common to all the user.

How can I set the header to:

  • have the most agressive cache (with a max-age of 60).
  • avoid mixing pages between users.

Can I replace my present header:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre开发者_如何学C-check=0", false);
header("Pragma: no-cache");

With this?

header('Cache-Control: public, max-age=60');
header('Vary: *');

Edit: Is it possible (how) to have it Cache-controled private in case "1" and public in case "2"


If login is purely cookie based then you only need a Vary: Cookie header to make it unique to a particular user. The Vary: * should work just as well though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜