Как настроить .htaccess для кэширования корня наряду со всеми другими файлами

Для моего веб-сайта все файлы кэшируются кроме файла index.html.

Для .htaccess я имею:

Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R=301,L]
DirectoryIndex /index.html
AddType text/html .html
AddOutputFilter INCLUDES .html
ErrorDocument 404 https://www.mywebsite.com/
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<Files 403.shtml>
order allow,deny
allow from all
</Files>
<IfModule mod_expires.c>
    ExpiresActive on

    ExpiresDefault "access plus 1 year"

    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/html "access plus 1 year"
    ExpiresByType text/javascript "access plus 1 year"
    ExpiresByType application/octet-stream "access plus 1 year"
    ExpiresByType text/css "access plus 1 year"

    <IfModule mod_headers.c>
        Header unset ETag
        Header append Cache-Control "public, no-transform"

        Header set X-UA-Compatible "IE=Edge,chrome=1"
        # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
        <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
                Header unset X-UA-Compatible
        </FilesMatch>
    </IfModule>
</IfModule>
FileETag None

Заголовок ответа для корня:

HTTP/1.1 200 OK
Date: Tue, 10 Mar 2015 21:11:03 GMT
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_fcgid/2.3.10-dev
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Cache-Control: max-age=31536000, public, no-transform
Expires: Wed, 09 Mar 2016 21:11:03 GMT
X-UA-Compatible: IE=Edge,chrome=1
Keep-Alive: timeout=5
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

Демонстрационный ответ из всех других файлов:

Accept-Ranges:bytes
Cache-Control:max-age=31536000, public, no-transform
Connection:Keep-Alive
Content-Encoding:gzip
Content-Type:text/css
Date:Tue, 10 Mar 2015 21:20:49 GMT
Expires:Wed, 09 Mar 2016 21:20:49 GMT
Keep-Alive:timeout=5
Last-Modified:Mon, 13 Oct 2014 01:18:29 GMT
Server:Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_fcgid/2.3.10-dev
Transfer-Encoding:chunked
Vary:Accept-Encoding

Единственная разница, которую я вижу, является этим Last-Modified отсутствует из корневого файла. Действительно ли это - проблема, и как она может быть добавлена к htaccess?

Как основной файл веб-сайта может кэшироваться, а также все другие?

0
задан 10 March 2015 в 23:26
1 ответ

ಈ ಕೆಳಗಿನ ಸಾಲನ್ನು ಕಾಮೆಂಟ್ ಮಾಡುವ ಮೂಲಕ HTML ಫೈಲ್‌ಗಳಲ್ಲಿ ಸರ್ವರ್-ಸೈಡ್ ಅನ್ನು ನಿಷ್ಕ್ರಿಯಗೊಳಿಸಲು ಪ್ರಯತ್ನಿಸಿ ಮತ್ತು ನಂತರ ಅಪಾಚೆ ಅದಕ್ಕೆ ಕಾರಣವಾಗಿದೆಯೇ ಎಂದು ನೋಡಲು ಮರುಪ್ರಾರಂಭಿಸಿ.

AddOutputFilter INCLUDES .html
0
ответ дан 5 December 2019 в 12:55

Теги

Похожие вопросы