0

For my website, all files are cached except the index.html file.

For .htaccess, I have:

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

The response header for root:

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

A sample response from all other files:

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

The only difference I can see is that Last-Modified is missing from the root file. Is this the problem, and how can it be added to htaccess?

How can the main website file be cached as well as all others?

Jim Bob
  • 101
  • 4

1 Answers1

0

Try disabling server-side includes in HTML files by commenting out the following line and then restarting Apache to see if that's what's causing it.

AddOutputFilter INCLUDES .html
g491
  • 973
  • 5
  • 7