问题原文
原帖链接 · Mukhar Jain · CC BY-SA 3.0
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?
已采纳解答
原帖链接 · Simon Hayter · CC BY-SA 3.0
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
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
