使用 apache mod_expires 緩存 php,php 文件的 mime 類型是什麼? (Use apache mod_expires to cache php, what is a mime type for php files?)


問題描述

使用 apache mod_expires 緩存 php,php 文件的 mime 類型是什麼? (Use apache mod_expires to cache php, what is a mime type for php files?)

我想在mod_expires中緩存php幾秒鐘,我找不到例子,沒有人想緩存它(我知道,我知道)。

我應該在ExpiresByType中放入什麼來緩存php ?


參考解法

方法 1:

Debian uses text/x‑php. https://packages.debian.org/sid/mime‑support

The IANA suggests text/x‑php or application/x‑php. https://www.ietf.org/rfc/rfc4329.txt

Please note that text/php or application/php probably won't work.

方法 2:

What should I put into ExpiresByType to cache php?

Whatever Content‑Type your PHP scripts are generating. text/html if they're generating HTML pages, for instance.

A better option is usually to generate Expires headers in PHP code.

(by QiaoLithilionuser149341)

參考文件

  1. Use apache mod_expires to cache php, what is a mime type for php files? (CC BY‑SA 2.5/3.0/4.0)

#mod-expires #apache #mime-types #PHP






相關問題

lighttpd 中靜態圖片的 expires.url 配置 (expires.url configuration for static images in lighttpd)

mod_expires.c 和 mod_headers.c 根據 google pagespeed 見解無法正常工作 (mod_expires.c and mod_headers.c not working according to google pagespeed insights)

Apache FilesMatch - 匹配正則表達式中的文件夾 (Apache FilesMatch - matching a folder in the regular expression)

mod_expires 為 3## 狀態碼發送 Cache-Control 標頭 (mod_expires sending Cache-Control headers for 3## status codes)

Apache:如何在未安裝 mod_expires 的情況下將 Expires 標頭添加到文件中 (Apache: How to add Expires headers to files without mod_expires installed)

PHP session_start() 覆蓋 HTTP Expires 標頭 (PHP session_start() overwrites HTTP Expires header)

添加過期標頭以提高使用 .htaccess 的頁面的性能 (Add expire header to improve the performance of page using .htaccess)

使用 apache mod_expires 緩存 php,php 文件的 mime 類型是什麼? (Use apache mod_expires to cache php, what is a mime type for php files?)







留言討論