4

I have read the other answers but all are based on editing the .htaccess file. Is there any way to set expiry without touching the .htaccess file?

5

Yes it is possible using Apache and PHP, by setting the expires and cache-control using header(), you can find out more about what is, and what is not supported in the HTTP/1.1 specification. PHP headers will look something like this:

$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");

You can find more help in regards of setting up PHP headers on Stack Overflow, here's a just few to get you started:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.