: How to specify expiry to a (css/js) files of a website in a shared hosting? I have read the other answers but all are based on editing the .htaccess file. Is there any way to set expiry
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?
More posts by @Rivera981
1 Comments
Sorted by latest first Latest Oldest Best
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:
Setting up Expire Headers with PHP.
PHP Header expires not working
PHP header expire every day at X
CSS PHP expire problem
Set expire headers through PHP
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.