此为历史版本和 IPFS 入口查阅区,回到作品页
Phanix
IPFS 指纹 这是什么

作品指纹

Specify cache expire time in Apache 2.4

Phanix
·
·

如果有某些檔案會經常更動(比方說一些 batch process 會將結果寫成 .html 檔),又希望每次瀏覽時能夠拿到最新的,而不是瀏覽器內的 cache,那可以在 apache2.4 內這樣設定

Alias /myfolder /var/opt/www/myfolderpath
        <Directory /var/opt/www/myfolderpath>
            Options FollowSymLinks Indexes
            DirectoryIndex index.html
            Require all granted
            AllowOverride All
                <filesMatch "\.(html)$">
                ExpiresActive on
                ExpiresDefault "access plus 10 minutes"
                Header merge Cache-Control public
                FileETag All
                </filesMatch>
        </Directory>

詳細參考以下這幾篇

  1. https://httpd.apache.org/docs/2.4/mod/mod_headers.html
  2. https://httpd.apache.org/docs/2.4/mod/mod_expires.html
  3. https://httpd.apache.org/docs/2.4/mod/mod_cache.html
  4. https://www.digitalocean.com/community/tutorials/how-to-configure-apache-content-caching-on-ubuntu-14-04

Original link: Phanix's Blog

CC BY-NC-ND 2.0 授权