I have a dynamic php site which generates a json string. So if a javascript does 10 requests to this site per minute the json string is generated and echoed 10 times.
I want to limit the requests going through to my server to 1 request per minute.
I thought the cache control header would do the job, but it looks like I'm wrong.
Here is what I tried. I set my php page to this:
<?php
header("Cache-Control: max-age=60");
echo "{'test':'abc'}";
?>
Loaded the site with the browser; it returned {'test':'abc'} Then I quickly changed the php page to:
<?php
header("Cache-Control: max-age=60");
echo "{'qwe':'123'}";
?>
Reloaded the page quickly and got: {'qwe':'123'}
So the second request went through even though the minute wasn't over. I wanted the first result to be returned from cache for one minute, without doing another request.
What am I doing wrong?