2014-01-08 58 views
0

我檢查我的Plesk控制面板上的我的VPS和安裝這些MODS的,但是當我通過http://redbot.org/運行現場檢查東西被髮送到了什麼,我得到:爲什麼mod_expires和mod_headers無法在我的服務器上工作?

This response is negotiated, but doesn't have an appropriate Vary header. 

The max-age Cache-Control directive appears more than once. 

Cache-Control: no-cache, max-age=0, must-revalidate, no-transform, max-age=300 

所以它看起來並不像它的加工。

下面是我編輯的.htaccess:

### SILVERSTRIPE START ### 
<Files *.ss> 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.1 
</Files> 

<Files web.config> 
    Order deny,allow 
    Deny from all 
</Files> 

# This denies access to all yml files, since developers might include sensitive 
# information in them. See the docs for work-arounds to serve some yaml files 
<Files *.yml> 
    Order allow,deny 
    Deny from all 
</Files> 

# Define some expiry header settings. 
<IfModule mod_expires.c> 
    ExpiresActive On 
    ExpiresByType text/html "access plus 5 minutes" 
    ExpiresByType image/gif "access plus 7 day" 
    ExpiresByType image/png "access plus 7 day" 
    ExpiresByType image/jpg "access plus 7 day" 
    ExpiresByType image/jpeg "access plus 7 day" 
    ExpiresByType image/ico "access plus 7 day" 
    ExpiresByType text/css "access plus 7 day" 
    ExpiresByType text/javascript "access plus 7 day" 
    ExpiresByType application/x-javascript "access plus 7 day" 
</IfModule> 

# Append the 'Vary: Accept-Encoding' for resources that might need it. 
<IfModule mod_headers.c> 
    <FilesMatch "\.(js|css|xml|gz)$"> 
    Header append Vary: Accept-Encoding 
    </FilesMatch> 
</IfModule> 

ErrorDocument 404 /assets/error-404.html 
ErrorDocument 500 /assets/error-500.html 

<IfModule mod_rewrite.c> 
    SetEnv HTTP_MOD_REWRITE On 
    RewriteEngine On 
    RewriteBase '/' 


    RewriteRule ^vendor(/|$) - [F,L,NC] 
    RewriteRule silverstripe-cache(/|$) - [F,L,NC] 
    RewriteRule composer\.(json|lock) - [F,L,NC] 

    RewriteCond %{REQUEST_URI} ^(.*)$ 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_URI} !\.php$ 
    RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L] 
</IfModule> 
### SILVERSTRIPE END ### 

我只是想以一個小的客戶端緩存添加到我的網站,我也建議增加老有所不同:接受編碼爲無法處理gzip的客戶 - 顯然這是最佳做法。

任何想法,我哪裏會出錯?

+0

我刪除了從我的.htaccess文件中添加的東西 - 這不會讓我得到任何地方。文檔中提到了一些默認的緩存標頭。據稱Silverstripe默認設置標題(請參閱http://doc.silverstripe.org/framework/en/howto/cache-control)。但是,在我的測試中,它始終將Cache-Control設置爲no-cache,而不是所述的「max-age = 86400」。我設法通過顯式調用我的網站的_config.php中的set_cache方法來覆蓋它。 –

回答

2

你的htaccess文件有

<IfModule mod_expires.c> 

這可能是你的VPS沒有安裝的Apache指定mod_expires。如果是這種情況,那麼expires配置將不適用。

+0

就像我說的,雖然我檢查了Plesk,並且該模塊已安裝且處於活動狀態。另外,它說'最大時間緩存控制指令不止一次出現'。暗示它正在工作,但被別的東西覆蓋(可能是銀條)。 –

相關問題