Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
722 views
in Q2A Core by

Hi There,

I wanna add these fields to the HTML Header:

  1. If-Modified-Since
  2. Last-Modified
  3. Content-Length
  4. ETag
  5. Expires
  6. Cache-Control

How I can do that?

Thanks,

Q2A version: 1.7.4

1 Answer

+3 votes
by

Content-Length is not possible because the final length of the page is not known ahead of time. That probably rules out ETag because that header is usually a hash of the content so you can't send that header after the content is output.

If-Modified-Since is not sent out by the server, rather it is sent by the browser to the server.

For the others, you'll probably want to look at a process module. Use the init_page() function and output the headers you want. I don't think there is a need to output more than one - Cache-Control is probably simplest:

class add_headers
{
    function init_page()
    {
        header('Cache-Control: private,max-age=600'); // 10 minutes
    }
}
by
I added header line into page.php and it works fine.
...