M
M
mrWan2017-11-01 17:54:18
PHP
mrWan, 2017-11-01 17:54:18

I can not understand why my page is not cached?

Tried all options, nothing works.
Here is one option:

header("Cache-Control: public");
header("Expires: " . date("r", time() + 3600));
echo "<h1>", date("H:i:s"), "</h1>";

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Anton Mashletov, 2017-11-01
@mashletov

header("Cache-control: public");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 60*60*24) . " GMT"); // на сутки

C
Cyril, 2017-11-01
@lilianz

Please describe the problem in more detail.

S
Salim_Gareev, 2017-11-01
@Salim_Gareev

This is not enough. In any case, the browser sends a request to the server with the question - has the data changed? The server sends a Status Code header with a value of 304 Not Modified and the browser loads the page from the cache if the data received from the browser matches.
Personally, I recommend using etag - it's more convenient.
ps I wanted to write that you must write this logic in the code, the server does not track php without you.

M
mrWan, 2017-11-01
@mrWan

Guys, give a couple of links to sensible things that you can read or watch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question