I am thinking about using mod_cache. However, the pages (created by php) that I want to cache Apache usually contain the username of this user ("You are logged in as ..."). Therefore, I canβt just cache one page for all users.
Login status is determined by cookie. So I thought that I could (in PHP) include the "Vary: Cookie" header on every page. If my understanding of RFC 2616 is correct, this should instruct the Apache (or any other) caching algorithm to cache a separate page for each individual Cookie value that is sent by the user agent.
So, if the cookie is not sent by the browser (the user logs out), the cached response is stored separately from the cached response to the request with Cookie: state = 89898XAAJ (the user is registered as "Jacob"), and this is again stored separately from the cached response to the request from Cookie : state = XXAIU2389 (user logged in as "Bob"). And if after some time the user requests the same URL and uses Cookie: state = 89898XAAJ, he will serve the correct page with "You are logged in as Jacob" (and not other cached ones).
Do I understand this correctly, and it will work like that, or am I not noticing something here?
source share