У меня возникла проблема при попытке включить кеширование браузера для веб-сайта, который обслуживается Apache на сервере Centos.
Я проделал все обычные шаги, которые раньше помогали мне при установке Ubuntu, поэтому на данный момент я немного озадачен. Я искал в Google, но пока не нашел причины, по которой им могут потребоваться разные настройки от Centos до Ubuntu. Возможно, стоит упомянуть, что mod_deflate отлично работает, любая помощь будет принята с благодарностью.
Версия Centos
rpm -q centos-release
centos-release-6-9.el6.12.3.x86_64
Версия Apache
rpm -q httpd
httpd-2.2.15-59.el6.centos.x86_64
Нет AllowOveride Нет в httpd.conf
grep 'AllowOverride' httpd.conf
AllowOverride All
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride All
# AllowOverride FileInfo AuthConfig Limit
# for additional configuration directives. See also the AllowOverride
AllowOverride All
AllowOverride All
AllowOverride All
Нет AllowOverride Нет на сайте VHost.conf
grep 'AllowOverride' /etc/httpd/conf.d/website-in-question.com.conf
AllowOverride All
Модули включены
apachectl -M | grep expires
expires_module (shared)
Syntax OK
apachectl -M | grep headers
headers_module (shared)
Syntax OK
.htaccess содержимое:
#SERVER COMPRESSION
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can't Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
<ifModule mod_headers.c>
Header set Connection keep-alive
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico|svg)$">
Header set Cache-Control "max-age=60, public"
</filesMatch>
</ifModule>
Оказывается, если я удалил следующие строки из .htaccess, он заработает:
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico|svg)$">
Header set Cache-Control "max-age=60, public"
</filesMatch>
Почувствуйте себя немного идиотом, но, по крайней мере, он работает!