Welcome Guest, Not a member yet? Register   Sign In
Cache-Control header always prepend "no-store, no-cache, must-revalidate"
#5

(This post was last modified: 08-22-2023, 03:10 PM by parisiam.)

(08-22-2023, 08:10 AM)ozornick Wrote: Session init in files? See session_cache_limiter() Turn off

Yes you're totally right !
Thank you very much for your hint Wink
It led me to the solution I found.
I'll develop it in my answer to Kenjis

(08-22-2023, 01:48 PM)kenjis Wrote: It is already reported:
https://github.com/codeigniter4/CodeIgni...ssues/7266

Sorry, I didn't check for the issues before posting my message.
I think I found the origin of the problem thanks to ozornick and a solution (that I implemented already, it works).

When using sessions (when the session starts), PHP automatically sends Cache-Control instruction to the header (see my initial post). It implicitely execute this instruction:
PHP Code:
session_cache_limiter('nocache'); 
See: https://www.php.net/manual/en/function.s...he-limiter

The problem is that the headers sent by session_cache_limiter() cannot be replaced or removed by CodeIgniter methods and functions such as:
PHP Code:
// removeHeader() does NOT remove the headers sent by session_cache_limiter()
$response->removeHeader('Cache-Control'); 

The solution is to stop theses headers from being issued BEFORE the session starts by using `session_cache_limiter('');`:
PHP Code:
// We prevent PHP from sending the cache related headers
session_cache_limiter('');
// Start the session
Services::session(); 

That's it. It's not really a bug of CodeIgniter, simply (for my part) the ignorance that when starting a session, PHP would send Cache related headers.

Thanks for your help.
Reply


Messages In This Thread
RE: Cache-Control header always prepend "no-store, no-cache, must-revalidate" - by parisiam - 08-22-2023, 03:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB