0

Im Using Symfony 2.3, and I have enabled the Symfony Reverse Proxy cache. It works, but not as I want it and not sure what to do.

So, User comes to site, visits a page. Logs in, navigates back to page viewed before login but is served the page he was shown before logging in, without any of the login changes. When logged in, I force pages not to cache, but its too late it seems when a page has already been cached by the reverse proxy, that cached page is server regardless.

Is there some way before a page is served via a cache I can determine that the request is coming from someone logged in so cache must be ignored?

1 Answers1

1

See this question and this question and make sure you tell the reverse proxy not to cache those routes by adding the right headers to your response for your reverse proxy and the user's cache.

$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
Community
  • 1
  • 1
Nicolai Fröhlich
  • 47,385
  • 11
  • 117
  • 125
  • I don't want to prevent the caching of pages, basically, when a logged in user requests a page I want to bypass the cache, in app.PHP the regular kernel gets converted to a cache kernel, I need somehow to check the regular kernel to see if the request is from an authenticated user, if so don't create the cache kernel. – user148313 Sep 25 '13 at 22:06