我有一個Web應用程序服務器,位於Apache 2.4.2後面的逆向代理配置中。該應用程序服務器返回包括下列頭的響應:Apache - 緩存來自應用程序服務器的響應
Pragma: no-cache
Vary: Accept-Encoding
Cache-Control: no-cache
Expires: Mon, 07 Jan 2013 01:21:30 GMT
我的Apache 2.4.2工作在此應用程序服務器的前反向代理,並希望緩存從應用服務器的響應。我無法修改應用程序服務器。我如何在Apache中執行此操作?我對CacheStoreExpired和CacheIgnoreCacheControl充滿希望,但他們在這裏沒有幫助,因爲Apache向後端發出了一個有條件的請求 - 而且應用服務器總是希望用現在過期的新內容刷新緩存。我想知道我是否可以重寫從應用程序服務器返回的頭文件?
我使用mod_cache的(沒有用)這個配置:
CacheEnable disk/
CacheRoot "C:/Program Files/Apache Software Foundation/Apache2.4/cache/"
CacheIgnoreCacheControl On
CacheIgnoreNoLastMod On
CacheStoreNoStore On
CacheStoreExpired On
CacheStaleOnError on
LogLevel debug
CacheHeader on
CacheDetailHeader on
CacheDefaultExpire 120
CacheMaxExpire 120
SetEnv proxy-nokeepalive 1
ProxyPass/http://localhost:8080/
Apache的調試日誌是有點令人擔憂,也:
[Fri Jan 04 16:27:52.113857 2013] [cache:debug] [pid 2824:tid 964] cache_storage.c(624): [client 192.168.4.36:51783] AH00698: cache: Key for entity /browse?(null) is http://192.168.4.189:80/browse?, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:52.113857 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(159): [client 192.168.4.36:51783] AH00750: Adding CACHE_SAVE filter for /browse, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:52.113857 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(169): [client 192.168.4.36:51783] AH00751: Adding CACHE_REMOVE_URL filter for /browse, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.503049 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(1190): [client 192.168.4.36:51783] AH00769: cache: Caching url: /browse, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.503049 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(1196): [client 192.168.4.36:51783] AH00770: cache: Removing CACHE_REMOVE_URL filter., referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.643529 2013] [cache_disk:debug] [pid 2824:tid 964] mod_cache_disk.c(1318): [client 192.168.4.36:51783] AH00737: commit_entity: Headers and body for URL http://192.168.4.189:80/browse? cached., referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.799618 2013] [cache:debug] [pid 2824:tid 964] cache_storage.c(624): [client 192.168.4.36:51783] AH00698: cache: Key for entity /browse?(null) is http://192.168.4.189:80/browse?, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.799618 2013] [cache_disk:debug] [pid 2824:tid 964] mod_cache_disk.c(569): [client 192.168.4.36:51783] AH00709: Recalled cached URL info header http://192.168.4.189:80/browse?, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.799618 2013] [cache_disk:debug] [pid 2824:tid 964] mod_cache_disk.c(865): [client 192.168.4.36:51783] AH00720: Recalled headers for URL http://192.168.4.189:80/browse?, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.799618 2013] [cache:debug] [pid 2824:tid 964] cache_storage.c(320): [client 192.168.4.36:51783] AH00695: Cached response for /browse isn't fresh. Adding/replacing conditional request headers., referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.799618 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(159): [client 192.168.4.36:51783] AH00750: Adding CACHE_SAVE filter for /browse, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:53.799618 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(169): [client 192.168.4.36:51783] AH00751: Adding CACHE_REMOVE_URL filter for /browse, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:55.235637 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(1190): [client 192.168.4.36:51783] AH00769: cache: Caching url: /browse, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:55.235637 2013] [cache:debug] [pid 2824:tid 964] mod_cache.c(1196): [client 192.168.4.36:51783] AH00770: cache: Removing CACHE_REMOVE_URL filter., referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:55.298072 2013] [cache_disk:warn] [pid 2824:tid 964] (OS 5)Access is denied. : [client 192.168.4.36:51783] AH00699: rename tempfile to file failed: C:/Program Files/Apache Software Foundation/Apache2.4/cache/aptmpcJvfPV -> C:/Program Files/Apache Software Foundation/Apache2.4/cache/A/3/xM0hz_t8XPQaojszgaGA.data, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:55.298072 2013] [cache_disk:debug] [pid 2824:tid 964] mod_cache_disk.c(617): [client 192.168.4.36:51783] AH00711: Deleting C:/Program Files/Apache Software Foundation/Apache2.4/cache/A/3/xM0hz_t8XPQaojszgaGA.header from cache., referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:55.298072 2013] [cache_disk:debug] [pid 2824:tid 964] mod_cache_disk.c(634): [client 192.168.4.36:51783] AH00713: Deleting C:/Program Files/Apache Software Foundation/Apache2.4/cache/A/3/xM0hz_t8XPQaojszgaGA.data from cache., referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:55.298072 2013] [cache_disk:debug] [pid 2824:tid 964] mod_cache_disk.c(674): [client 192.168.4.36:51783] AH00715: Deleting directory C:/Program Files/Apache Software Foundation/Apache2.4/cache/A/3 from cache, referer: http://192.168.4.189/browse
[Fri Jan 04 16:27:55.298072 2013] [cache_disk:debug] [pid 2824:tid 964] mod_cache_disk.c(1313): [client 192.168.4.36:51783] AH00736: commit_entity: URL 'http://192.168.4.189:80/browse?' not cached due to earlier disk error., referer: http://192.168.4.189/browse
嗨戴夫,你有沒有想到你的配置有什麼問題?你是否修復了「由於較早的磁盤錯誤而未緩存」的錯誤? – freedev
我放棄了!我認爲'重命名tempfile文件失敗'警告是Windows上的Apache(http://goo.gl/HPSb4)中的一個錯誤。 Mod_headers剝離了源服務器的反高速緩存響應(Header unset Expires),它允許Apache啓動緩存,但是然後mod_expires無法設置計算的過期,也不能將緩存頭重新插入緩存中的響應以防止在網絡中的其他地方緩存)。然後,當瀏覽器的請求包含max-age = 0(讓我驚慌)時,Apache從緩存中提供了一些東西。最終,我意識到我需要在應用程序層緩存,而不是HTTP。 – dave