Mobile app version of vmapp.org
Login or Join
Rivera981

: 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

@Rivera981

Posted in: #Expires #Html #SharedHosting

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Rivera981

1 Comments

Sorted by latest first Latest Oldest Best

 

@Radia820

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme