4

Laravel App Version 5.6 i wish to remove the value private from the Cache-Control Header which is presented in the API response

enter image description here

i have a middleware that is adding the "no-cache" and "no-store" values

    $response = $next($request);
    $response->headers->set('Cache-Control', 'no-cache, no-store');
    return $response;

is it possible to do it in the same Middleware or any other work around

EDIT1 : in PHP.ini i have left the value "session.cache_limiter" empty, made sure .htacess is not appending headers and changed my middleware to do the following

$response->headers->remove('Cache-Control');
$response->headers->set('Cache-Control', 'no-cache, no-store');

still getting the private value in the header.

maces
  • 169
  • 1
  • 9
  • wait, what's the problem with that private value? – Smankusors Jan 03 '19 at 04:39
  • uh oh... can you check other middlewares? – Smankusors Jan 03 '19 at 04:53
  • yeah i did none of them is adding the private value – maces Jan 03 '19 at 04:55
  • this might help you https://stackoverflow.com/questions/12908766/what-is-cache-control-private – HilAy Patel Jan 03 '19 at 05:20
  • @HilAyPatel that was a nice description however i don't want to know what it means but rather i wish to remove the private value! using a laravel method or tooling ........ – maces Jan 03 '19 at 08:04
  • 1
    I think it's set by default by `symfony\http-foundation\ResponseHeaderBag`. It looks like it want to set `private` or `public`, you can't remove it. Unless you edit the `computeCacheControlValue()` function – Smankusors Jan 04 '19 at 05:52
  • @Smankusors absolutely correct if i follow the logic unless i append s-maxage to cache-control it will add private by default it's a bit weird but still the way it works please write this as an answer so i can mark it correct thanks a lot dude – maces Jan 04 '19 at 08:13
  • wait, you previously only want no-cache and no-store... well to be honest, the `private` value itself looks okay for me, instead adding weird `s-maxage` :D – Smankusors Jan 04 '19 at 14:05
  • @Smankusors yeah but changing Symphony is not acceptable setting `s-maxage=0` is kind of acceptable while I know this would practically do the same job as `private` this is more acceptable apparently. – maces Jan 05 '19 at 04:17

0 Answers0