apache2 - is it possible to cache a php page that have "GET" variables with 'Cache-Control: public, max-age=n' header?


i have this php page that looks like this:


it's accessed publicly and return the same content when provided with the same variables -"GET" variables that are included in the link- ,and i can't seem to have the browser cache the page so it won't bother the server every time the page is needed!

I've tried and added this line to the head of get_data.php but no luck header('Cache-Control: public, max-age=7200');

this is the php file code:

header('Content-type: application/json');
header('Cache-Control: public, max-age=7200');

$link_database = new mysqli($host,$dbusername,$dbpassword,$database);

accessed like this in javascript:

xmlhttp.open("GET", "/get_data.php?forid="+forid+"&pdid="+pdid+"&exclude_ids="+existing_ids.join(","), true);

tested with firefox i get this raw response headers:

HTTP/1.1 200 OK
Date: Sat, 15 Jun 2019 16:04:54 GMT
Server: Apache/2.4.25 (Debian)
Cache-Control: public, max-age=7200
Keep-Alive: timeout=5, max=91
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json

is what i'm trying to do even a possibility? if it is, how can i?

ps: the php code execute a simple sql, and a pure php cache system will not give any advantages(i think!).

People are also looking for solutions to the problem: How to style HTML element with PHP


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.