2012-09-28 24 views
0

我使用谷歌應用程序引擎的Java SDK 1.7.2服務於一些靜態文件。當組合多個在AppEngine上-web.xml中<static-files><include...元素,我不能確定哪些規則爲準。GAE的Java SDK:AppEngine上-web.xml中 「<static-file><包括......」 優先

例如,我有以下幾點:

<static-files> 
    <include path="/**.swf" expiration="365d"></include> 
    <include path="/**.jpg" expiration="365d"></include> 
    <include path="/**"></include>  
    <exclude path="/**.php"></exclude> 
</static-files> 

我相信這個規定,一切都應該被包含在靜態存儲,除了.php文件,而瑞士法郎和.jpg文件應該有「的cache控制「和」過期「將在365天后設置的http標題。

然而,使用Live HTTP標題工具,Firefox的時候,我看不出對靜態文件的預期頭與長呼氣:

http://localhost:8888/swf/Logo.20120927.swf 

GET /swf/Logo.20120927.swf HTTP/1.1 
Host: localhost:8888 
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0.1 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-gb,en-us;q=0.7,en;q=0.3 
Accept-Encoding: gzip, deflate 
DNT: 1 
Connection: keep-alive 
Referer: http://localhost:8888/ 
If-Modified-Since: Thu, 27 Sep 2012 15:49:03 GMT 
Cache-Control: max-age=0 

HTTP/1.1 304 Not Modified 
Server: Jetty(6.1.x) 
---------------------------------------------------------- 
http://localhost:8888/images/logo-and-buttons.20120927.jpg 

GET /images/logo-and-buttons.20120927.jpg HTTP/1.1 
Host: localhost:8888 
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0.1 
Accept: image/png,image/*;q=0.8,*/*;q=0.5 
Accept-Language: en-gb,en-us;q=0.7,en;q=0.3 
Accept-Encoding: gzip, deflate 
DNT: 1 
Connection: keep-alive 
Referer: http://localhost:8888/ 
If-Modified-Since: Thu, 27 Sep 2012 15:49:03 GMT 
Cache-Control: max-age=0 

HTTP/1.1 304 Not Modified 
Server: Jetty(6.1.x) 

我的問題是,如果不工作不如預期,那麼如何配置我的<static-files>元素以達到預期的效果?

乾杯,

傑夫。

+1

我已經回答了我自己的問題: 我得到「緩存控制:max-age」值爲0,並且在我的HTTP頭文件中沒有「過期」值的原因是因爲我只是重新加載頁面Firefox瀏覽器。 一旦啓動新的隱私瀏覽會話(復位的過程中高速緩存),並加載頁面的第一次,我收到了預期的頭。 – Jeff

回答

0

我已經回答了我的問題:我之所以變得「緩存控制:最大年齡」的0值,並在我的HTTP標頭中沒有「過期」的價值觀,是因爲我剛剛重裝Firefox中的頁面。在開始新的專用瀏覽會話(重置進程中的緩存)並首次加載頁面時,我收到了預期的標題。

+0

我認爲,對於未被緩存資源最主要的原因就是您登錄作爲GAE管理員,但我不明白這種行爲對我們的部署應用程序。 –

相關問題