Помогите пожалуйста активировать кеширование. Много чего уже перепробовал, но вот PageSpeed Insight так и не видит того, что оно есть.
Ставил: memcached, pagespeed, mod_expires, mod_headers, mod_deflate;
Прописывал настройки в nginx
Так же добавлял строки в .htaccess
В итоге, когда вбиваем сайт в pagespeed insights гугла, рекомендация "Используйте кеш браузера" сохраняется. Пишет, что для картинок не указан срок действия. Подскажите пожалуйста, как исправить? Везде же вроде срок указан?
Ставил: memcached, pagespeed, mod_expires, mod_headers, mod_deflate;
Прописывал настройки в nginx
Код |
---|
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|pdf|ppt|txt|bmp|rtf|js)$ { root /var/www/gal/data/www/; expires 7d;} location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|pdf|ppt|txt|bmp|rtf|js)$ { root /var/www/gal/data/www/; expires 7d;} location ~* ^.+\.(rss|atom|jpg|jpeg|gif|png|ico|rtf|js|css)$ { expires 7d; } location / { default_type text/html; set $memcached_key "$server_name:$request_uri"; memcached_pass 127.0.0.1:11211; } location ~* ^.+.(html|jpg|jpeg|gif|css|png|js|ico|gz)$ { expires 60d; proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_cache static_cache; proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri"; proxy_cache_valid 1d; } proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=static_cache:100m inactive=120m max_size=500M; proxy_cache_min_uses 1; |
Так же добавлял строки в .htaccess
Код |
---|
FileETag MTime Size <ifmodule mod_expires.c> <filesmatch ".(jpg|jpeg|gif|png|ico|css|js)$"> ExpiresActive on ExpiresDefault "access plus 1 year" </filesmatch> </ifmodule> <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 AddOutputFilterByType DEFLATE image/gif AddOutputFilterByType DEFLATE image/png AddOutputFilterByType DEFLATE image/jpeg AddOutputFilterByType DEFLATE image/jpg </ifModule> </ifModule> <ifModule mod_headers.c> # Все html и htm файлы будут храниться в кэше браузера один день <FilesMatch "\.(html|htm|gif|jpg|jpeg|png)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> # Все css, javascript и текстовые файлы будут храниться в кэше браузера одну неделю <FilesMatch "\.(js|css|txt|gif|jpg|jpeg|png)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> # Все флэш файлы и изображения будут храниться в кэше браузера один месяц <FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> # Отключаем кеширование php и других служебных файлов <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi|gif|jpg|jpeg|png)$"> Header unset Cache-Control </FilesMatch> </IfModule> <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 month" # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) ExpiresByType text/cache-manifest "access plus 0 seconds" # html ExpiresByType text/html "access plus 1 month" # XML ExpiresByType text/xml "access plus 1 month" ExpiresByType application/xml "access plus 1 month" # RSS ExpiresByType application/rss+xml "access plus 1 month" # Favicon ExpiresByType image/x-icon "access plus 1 month" # Картинки ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" # HTC файлы (например css3pie) ExpiresByType text/x-component "access plus 1 month" # Нестандартные шрифты сайта ExpiresByType application/x-font-ttf "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" ExpiresByType application/x-font-woff "access plus 1 month" ExpiresByType image/svg+xml "access plus 1 month" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" # CSS и javascript ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" </IfModule> <ifModule mod_headers.c> <filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=2592000, public" </filesMatch> <filesMatch "\.(css|js)$"> Header set Cache-Control "max-age=2592000, public" </filesMatch> <filesMatch "\.(xml|txt)$"> Header set Cache-Control "max-age=2592000, public, must-revalidate" </filesMatch> <filesMatch "\.(html|htm|php)$"> Header set Cache-Control "max-age=2592000, private, must-revalidate" </filesMatch> </ifModule> <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl|jpg|png|gif|jpeg)$ mod_gzip_item_include mime ^text\.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image\.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule> |
В итоге, когда вбиваем сайт в pagespeed insights гугла, рекомендация "Используйте кеш браузера" сохраняется. Пишет, что для картинок не указан срок действия. Подскажите пожалуйста, как исправить? Везде же вроде срок указан?