Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Warn about PHP sessions in documentation #4

Open
kAlvaro opened this issue Aug 15, 2019 · 1 comment
Open

Warn about PHP sessions in documentation #4

kAlvaro opened this issue Aug 15, 2019 · 1 comment

Comments

@kAlvaro
Copy link

kAlvaro commented Aug 15, 2019

This library works like a charm but there was an issue that kept me hitting a wall. It'd be nice if it was mentioned somewhere in the README file.

PHP session handler generates its own headers. The exact ones depend on the session.cache_limiter directive. Its default value is nocache and that means you get:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache

This interferes completely with \Micheh\Cache\CacheUtil::withCache(). Only Cache-Control finally gets the value set by this method. It's also not obvious at first sight because these extra headers are set by PHP core and are invisible for PSR-7 implementations (at least the one I'm using).

It's not necessarily the library's fault but it can lead you to wonder why it isn't working. If you want to cache responses from session based applications you need to set session.cache_limiter to something that's not the default, e.g.:

ini_set('session.cache_limiter', 'public');

Reference can be found at session_cache_limiter() manual page.

@zkwbbr
Copy link

zkwbbr commented May 7, 2020

This is actually quite a big deal. I'm not really using this library at the moment (although I think I will) but I came across this post which solved my issue with a PSR-7 lib not properly setting Cache-Control because I have sessions started. Thank you for pointing this out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants