开发者

Rails 3, apache, passenger, cache, wrong content-type for cached pages

开发者 https://www.devze.com 2023-03-28 20:51 出处:网络
I added page caching to my app. Cache is stored in public/cache directory. I have a strange error: for some cached pages apache returns content-type text/plain instead of text/html.

I added page caching to my app. Cache is stored in public/cache directory.

I have a strange error: for some cached pages apache returns content-type text/plain instead of text/html.

Cached pages which are in root cached folder (public/cache) eg. public/cache/page1.html are served with content type text/plain. Only index.html page from root folder is served with correct content type (text/html)

But开发者_如何学C pages which are in subsolders eg public/cache/subfolder/page2.html are served with text/html content type.

I have no idea why it happens.

My .htaccess file in public folder

RewriteEngine On

RewriteCond %{REQUEST_URI} ^([^.]+)/$
RewriteRule ^[^.]+/$ /%1 [QSA,L]

RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^([^.]+)$
RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f
RewriteRule ^[^.]+$ /cache/%1.html [QSA,L]

RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
RewriteRule ^$ /cache/index.html [QSA,L]

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:pdf|doc)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:avi|mov|mp3|mp4|rm)$ no-gzip dont-vary

ExpiresActive On

# Expires after a month client accesses the file
ExpiresByType image/jpeg A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000

Any idea?

0

精彩评论

暂无评论...
验证码 换一张
取 消