Score:0

Multiple cache headers

ua flag

So I'm running a drupal site and I'd like the response of a specific URL to be cached:

I've added this code in the PHP function:

  $seconds_to_cache = 3600;
  $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
  header("Expires: $ts");
  header("Pragma: cache");
  header("Cache-Control: max-age=$seconds_to_cache");

But the response has the following headers:

cache-control: max-age=3600 <-- Looks like my header
cache-control: must-revalidate, no-cache, private <-- Why is this still here ?
content-encoding: gzip
content-language: fr
content-type: application/json
date: Wed, 09 Feb 2022 11:47:05 GMT
expires: Wed, 09 Feb 2022 12:47:05 GMT <-- also looks like my header
expires: Sun, 19 Nov 1978 05:00:00 GMT <-- Why is this still here ?

My headers seem to be present, but they don't seem to override the default headers which are just below. So my question: Are multiple headers a problem ? Which one is taken into account ? How can I make it clear to Apache that I want to override the default headers ?

us flag
I think the additional header comes from Drupal. You need to find a Drupal compatible way to control the cache headers. Drupal should have internal APIs to control HTTP cache headers.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.