Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Htaccess Rules For Google Pagespeed Insights In 2021, The best rules for Htaccess for Apache servers
Web Design Seo
post Mar 18 2021, 01:58 PM
Post #1


Web Design Seo
****

Group: Root Admin
Posts: 4,332
Joined: 29-April 09
From: Sofia
Member No.: 1



Effective Htaccess rules to successfully pass the Google PageSpeed Insights check in 2021 - cache, gzip and other rules for Apache servers. Include compression and caching of woff and woff2 fonts, all necessary file types and webp images. Latest version. Updated 2021 for latest PageSpeed Insights, these Htaccess rules have been tested on over 150 websites.

Код
<IfModule mod_deflate.c>
<FilesMatch "\.(ttf|otf|eot|woff|woff2|svg|ico|pdf|flv|jpg|jpeg|png|gif|webp|js|css|swf)(\.gz)?$">
SetOutputFilter DEFLATE
Header set Expires "max-age=31536000, public"
Header unset ETag
FileETag None
</FilesMatch>
</IfModule>

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-woff
AddOutputFilterByType DEFLATE application/x-font-woff2
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/eot
AddOutputFilterByType DEFLATE font/woff
AddOutputFilterByType DEFLATE font/woff2
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType image/x-icon "access plus 12 month"
ExpiresByType application/x-font-woff "access plus 12 month"
ExpiresByType application/x-font-woff2 "access plus 12 month"
ExpiresByType image/icon "access plus 12 month"
ExpiresByType application/x-javascript "access plus 3 month"
ExpiresByType text/javascript "access plus 3 month"
ExpiresByType text/css "access plus 3 month"
ExpiresByType image/gif "access plus 3 month"
ExpiresByType image/png "access plus 3 month"
ExpiresByType image/bmp "access plus 3 month"
ExpiresByType image/jpeg "access plus 3 month"
ExpiresByType image/webp "access plus 3 month"
ExpiresByType text/plain A1200
ExpiresByType application/x-shockwave-flash "access plus 3 month"
ExpiresByType video/x-flv "access plus 3 month"
ExpiresByType application/pdf "access plus 3 month"
ExpiresByType text/html A6000
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "\.(ttf|otf|woff|woff2|svg|ico|pdf|flv|swf|js|css|gif|png|jpg|jpeg|webp|ico|txt|html|htm)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary Accept-Encoding
  </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)$
  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 mod_headers.c>
  Header set Connection keep-alive
</IfModule>

Go to the top of the page
 
+Quote Post
Web Design Seo
post Mar 18 2021, 02:07 PM
Post #2


Web Design Seo
****

Group: Root Admin
Posts: 4,332
Joined: 29-April 09
From: Sofia
Member No.: 1



You can see the warning in Google PageSpeed Insights on picture bellow:



If you do not have any caching rules, you will get a very good effect on the speed of your site even from these htaccess rules alone.


--------------------
Правила на форума | Forum Rules | How to receive support. 3D Web Design: Уеб дизайн, Seo оптимизация, Web Site Extensions, Oscommerce Addons, Wordpress plugins and Joomla Extensions. Изработка на уеб сайтове и оптимизация на сайт за търсачки и Seo услуги.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
3 User(s) are reading this topic (3 Guests and 0 Anonymous Users)
0 Members:

Collapse

> Similar Topics

  Topic Replies Topic Starter Views Last Action
No new Pinned: Htaccess Code To Speed Up Joomla
example code for Htaccess for Joomla, Wordpress and other CMS
8 Web Design Seo 61,741 17th February 2021 - 11:43 AM
Last post by: Web Design Seo
No New Posts Htaccess Code To Switch To Other Php Version
Htaccess Code To Switch To php 5.6
1 Web Design Seo 39,341 17th August 2020 - 08:58 AM
Last post by: Web Design Seo
No New Posts Google Penguin 3 Results
Penguin 3.0 recap - many sites again on positions, evidence
0 Web Design Seo 107,064 14th November 2014 - 08:40 AM
Last post by: Web Design Seo
No new Google Plus услуги
предлагани услуги за Google+ и цени
6 Web Design Seo 93,951 15th August 2014 - 09:47 AM
Last post by: Web Design Seo
No New Posts Google's Penguin One And Penguin 2.0 Differences
the difference between Penguin 1 and Penguin 2.0
1 Web Design Seo 96,451 22nd July 2014 - 06:49 AM
Last post by: Web Design Seo
No New Posts Pinned: Google Play Seo
SEO за Android приложения и чрез приложения за Андроид
1 Web Design Seo 78,690 16th April 2014 - 08:07 AM
Last post by: Web Design Seo
No New Posts Pinned: Google Disavow Links инструмент
инструмент за отказване от "лоши линкове"
2 Web Design Seo 106,093 10th March 2014 - 01:28 PM
Last post by: Web Design Seo
No New Posts Format Lost In Post By E-mail
3 gibor 164,258 9th January 2014 - 07:00 AM
Last post by: Web Design Seo
No new Google Penguin 2.0 идва
Ъпдейта на Google Пингвин 2 започна вчера
4 Web Design Seo 100,034 1st July 2013 - 10:07 AM
Last post by: Web Design Seo
No New Posts Pinned: Google Penguin примери
сайтове наказани от Google Penguin
0 Web Design Seo 80,310 10th April 2013 - 08:09 AM
Last post by: Web Design Seo


 



RSS Lo-Fi Version Time is now: 1st June 2026 - 09:19 PM