netkoLiX adlı üyeden alıntı:
mesajı görüntüle
Pagespeed sayyac ve analytics hatası
10
●3.871
- 09-09-2016, 20:10:16Optimizasyon işlerinde .htaccess dosyası da etkilidir.
Benim kendi kullandığım .htaccess dosyasının kodlarını sizlerle paylaşıyorum. Çoğu imajların önbelleklemesini bu kodlarla sağlayabilirsiniz.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> <ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ 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> <IfModule deflate_module> <IfModule filter_module> AddOutputFilterByType DEFLATE text/plain text/html AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript </IfModule> </IfModule> # Enable GZIP <ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </ifmodule> # Expires Headers - 2678400s = 31 days <ifmodule mod_expires.c> ExpiresActive On ExpiresDefault A0 ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/jpg "access 1 year" ExpiresByType image/ico "access 1 year" ExpiresByType image/svg+xml "access 1 month" ExpiresByType text/css "access 1 month" ExpiresByType text/javascript "access 1 month" ExpiresByType application/javascript "access 1 month" ExpiresByType application/x-javascript "access 1 month" </ifmodule> # Cache Headers <ifmodule mod_headers.c> # Cache specified files for 31 days <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"> Header set Cache-Control "max-age=2678400, public" </filesmatch> # Cache HTML files for a couple hours <filesmatch "\.(html|htm)$"> Header set Cache-Control "max-age=7200, private, must-revalidate" </filesmatch> # Cache PDFs for a day <filesmatch "\.(pdf)$"> Header set Cache-Control "max-age=86400, public" </filesmatch> # Cache Javascripts for 31 days <filesmatch "\.(js)$"> Header set Cache-Control "max-age=2678400, private" </filesmatch> </ifmodule> # ---------------------------------------------------------------------- # Webfont access # ---------------------------------------------------------------------- # allow access from all domains for webfonts # alternatively you could only whitelist # your subdomains like "sub.domain.com" <FilesMatch "\.(ttf|otf|eot|woff|font.css)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch> # webfont mime types AddType application/vnd.ms-fontobject eot AddType font/truetype ttf AddType font/opentype otf AddType application/x-font-woff woff # webfonts and svg: <IfModule mod_deflate.c> <FilesMatch "\.(ttf|otf|eot|svg)$" > SetOutputFilter DEFLATE </FilesMatch> </IfModule> <IfModule mod_headers.c> Header set Connection keep-alive Header set Expires "max-age=2592000, public" Header unset ETag </IfModule> # END WordPress
