簡體   English   中英

為什么mod_expires和mod_headers不能在我的服務器上運行?

[英]Why are mod_expires and mod_headers not working on my server?

我已經檢查了我的vps上的plesk控制面板並安裝了那些mod,但當我通過http://redbot.org/運行網站檢查發送的內容時,我得到:

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的客戶端添加舊的Vary:Accept-Encoding - 顯然這是最好的做法。

我在這里出錯的任何想法?

你的htaccess文件有

<IfModule mod_expires.c>

可能是您的VPS沒有為apache安裝mod_expires。 如果是這種情況,則有意義的是,expires配置將不會被應用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM