.htaccess 缓存静态内容(除非修改)?
想知道这在 .htaccess 中是否可能?
我目前正在通过 PHP 缓存 .js、.css 和所有图像文件(并且仅当文件未通过检查 filemtime() 修改时才提供缓存)。
然而,有人建议可以通过 .htaccess 并且更快,所以希望有人可以提供一些线索...我环顾四周,发现了各种片段,但没有一个片段涵盖了我所追求的内容。
Was wondering is this possible in .htaccess?
I'm currently caching .js, .css and all image files via PHP (and providing the cached only if the file has not been modified by checking the filemtime()).
However someone suggested it's possible via .htaccess and much faster, so was hoping maybe someone can shed some light...I've looked around and found various snippets but none which cover what I'm after.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你的 apache 服务器上安装了 mod_expires 你可以放一些东西就像在您的
.htaccess
文件中一样。这个示例是面向 PHP 的(实际上是从 Drupal 7.htaccess
文件中获取的),但应该作为一个很好的起点。If you've got mod_expires installed on your apache server you can put something like this in your
.htaccess
file. This example is PHP orientated (actually grabbed from the Drupal 7.htaccess
file) but should serve as a good starting point.