Оптимизация сайта,включить сжатие и кеширование на сервере Centos?

В общем,суть такая:
есть сайт который лежит на сервере Centos. Нужно включить сжатие и кеширование.
Добавил данный код в httacess
### Сжать ответ сервера для перечисленных MIME типов
<ifModule mod_deflate.c>
  <IfModule mod_filter.c>
      AddOutputFilterByType DEFLATE text/plain text/html
      AddOutputFilterByType DEFLATE text/css
      AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
      AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/rss+xml
      AddOutputFilterByType DEFLATE application/json
      AddOutputFilterByType DEFLATE application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon
  </ifModule>
</ifModule>


### Способ #1
### Подсказать браузеру схему кеширования через заголовки в ответе сервера
<ifModule mod_headers.c>
    # 43200 - день, 604800 - неделя, 2592000 - месяц
    <FilesMatch "\.(html|js|css)$">
	Header set Cache-Control "max-age=2592000"
        #Header unset Last-Modified
    </FilesMatch>
    <Files *.txt>
	Header add Cache-Control "max-age=43200"
    </Files>
    <FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
	Header set Cache-Control "max-age=2592000"
    </FilesMatch>
    <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
	# отключить кэширование
	Header unset Cache-Control
    </FilesMatch>
</IfModule>

### Способ #2
### Подсказать браузеру схему кеширования через заголовки в ответе сервера
<IfModule mod_expires.c>
    # Enable expires
    ExpiresActive On
    
    # Default a cache expiration
    ExpiresDefault "access plus 10 month"
    
    # Images
    ExpiresByType image/gif                 "access plus 1 month"
    ExpiresByType image/png                 "access plus 1 month"
    ExpiresByType image/jpg                 "access plus 1 month"
    ExpiresByType image/jpeg                "access plus 1 month"
    
    # CSS, JavaScript
    ExpiresByType text/css                  "access plus 1 year"
    ExpiresByType application/javascript    "access plus 1 year"
    ExpiresByType text/javascript           "access plus 1 year"
</IfModule>


### Удалить заголовок ETag (иначе есть проблемы с кешированием при включенном сжатии)
<IfModule mod_headers.c>
    Header unset ETag
</IfModule>
FileETag None


Не помогло,судя по гугл page speed,хотя показывает что gzip включен на других ресурсах.
  • Вопрос задан
  • 517 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы