我一直在試圖弄清楚我可以在我的網站上爲我的網站設置緩存設置,但我無法在其文檔中找到相關信息,Google也沒有產生任何結果。我讀了很多關於緩存的內容,但是我發現的所有結果或代碼示例都使用Apache。如何使用Java在GAE中設置網頁緩存設置?
任何文檔鏈接?或者只是我實際寫入緩存設置的一般信息?也許在某處appengine-web.xml
?
謝謝。任何信息/文檔都將不勝感激。
編輯:我已經試過這樣的事情在appengine-web.xml
,但它似乎是真的緩存什麼都不當我和Chrome瀏覽器開發工具測試 -
<static-files>
<include path="/**.png" expiration="7d" />
<include path="/**.jpg" expiration="7d" />
<include path="/**.ico" expiration="7d" />
<include path="/**.js" expiration="7d" />
<include path="/**.svg" expiration="7d" />
<include path="/**.ttf" expiration="7d" />
<include path="/**.woff" expiration="7d" />
<include path="/**.css" />
</static-files>
而且只要我添加單靜態文件是這樣的:
<static-files>
<include path="/img/top_img.jpg" expiration="4d 5h" />
</static-files>
我得到一噸的錯誤說我需要在我的靜態文件列表一切,像這樣的 - WARNING: Can not serve /paypal_button.svg directly. You need to include it in <static-files> in your appengine-web.xml.
編輯:這裏是捲曲-v日誌 -
< HTTP/1.1 200 OK
< Content-Length: 61009
< Content-Type: text/html
< Last-Modified: Wed, 13 Jan 2016 06:19:21 GMT
< Cache-Control: public, max-age=600
< Server: Development/1.0
< Date: Wed, 13 Jan 2016 07:33:39 GMT
所以啓用緩存..但我想不出如何如何改變使用GAE單個靜態文件到期日期。
編輯:當我測試棒的服務器上使用此代碼:我的資源負載的
<static-files>
<include path="/**.png" expiration="999d" />
</static-files>
無,我得到這些錯誤:
Failed to load resource: the server responded with a status of 404 (Not Found)
上的一切,是不是.png
你在這裏緩存是什麼意思? –
很抱歉,如果不清楚,我有一個網站託管在GAE上,我需要爲靜態文件設置我的緩存設置(當它們到期時設置等) – shanling
這樣? https://cloud.google.com/appengine/docs/java/config/appconfig#Java_appengine_web_xml_Static_cache_expiration –