|
1 | 1 | <IfModule mod_rewrite.c> |
| 2 | + # Start Engine |
| 3 | + RewriteEngine On |
2 | 4 |
|
3 | | - # page speed |
4 | | - <IfModule pagespeed_module> |
5 | | - ModPagespeed on |
6 | | - ModPagespeedEnableFilters rewrite_css,combine_css |
7 | | - ModPagespeedEnableFilters recompress_images |
8 | | - ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp |
9 | | - ModPagespeedEnableFilters collapse_whitespace,remove_comments |
10 | | - </IfModule> |
11 | | - |
12 | | - #Enable gzip compression for resources |
13 | | - <ifModule mod_gzip.c> |
14 | | - mod_gzip_on Yes |
15 | | - mod_gzip_dechunk Yes |
16 | | - mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ |
17 | | - mod_gzip_item_include handler ^application/x-httpd-php |
18 | | - mod_gzip_item_include mime ^application/javascript$ |
19 | | - mod_gzip_item_include mime ^application/x-javascript$ |
20 | | - mod_gzip_item_include mime ^text/.* |
21 | | - mod_gzip_item_exclude mime ^image/.* |
22 | | - mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* |
23 | | - </ifModule> |
24 | | - |
25 | | - # Compress resources |
26 | | - <IfModule mod_deflate.c> |
27 | | - SetOutputFilter DEFLATE |
28 | | - AddOutputFilterByType DEFLATE text/html |
29 | | - AddOutputFilterByType DEFLATE application/xhtml+xml |
30 | | - AddOutputFilterByType DEFLATE text/css |
31 | | - AddOutputFilterByType DEFLATE text/javascript |
32 | | - AddOutputFilterByType DEFLATE text/xml |
33 | | - AddOutputFilterByType DEFLATE text/plain |
34 | | - AddOutputFilterByType DEFLATE image/x-icon |
35 | | - AddOutputFilterByType DEFLATE image/svg+xml |
36 | | - AddOutputFilterByType DEFLATE application/rss+xml |
37 | | - AddOutputFilterByType DEFLATE application/javascript |
38 | | - AddOutputFilterByType DEFLATE application/x-javascript |
39 | | - AddOutputFilterByType DEFLATE application/xml |
40 | | - AddOutputFilterByType DEFLATE application/x-font |
41 | | - AddOutputFilterByType DEFLATE application/x-font-truetype |
42 | | - AddOutputFilterByType DEFLATE application/x-font-ttf |
43 | | - AddOutputFilterByType DEFLATE application/x-font-otf |
44 | | - AddOutputFilterByType DEFLATE application/x-font-opentype |
45 | | - AddOutputFilterByType DEFLATE application/vnd.ms-fontobject |
46 | | - AddOutputFilterByType DEFLATE font/ttf |
47 | | - AddOutputFilterByType DEFLATE font/otf |
48 | | - AddOutputFilterByType DEFLATE font/opentype |
49 | | - BrowserMatch ^Mozilla/4 gzip-only-text/html |
50 | | - BrowserMatch ^Mozilla/4\.0[678] no-gzip |
51 | | - BrowserMatch \bMSIE !no-gzip !gzip-only-text/html |
52 | | - Header append Vary User-Agent env=!dont-vary |
53 | | - </IfModule> |
| 5 | + # Cache-busting rule |
| 6 | + RewriteCond %{QUERY_STRING} !cache-buster [NC] |
| 7 | + RewriteRule \.(php|html)$ %{REQUEST_URI}?cache-buster=%{TIME_SEC} [L] |
| 8 | + |
| 9 | + # Disable caching for PHP files |
| 10 | + RewriteCond %{ENV:REDIRECT_NO_CACHE} !^$ |
| 11 | + RewriteRule \.php$ - [E=NO_CACHE:1] |
54 | 12 |
|
55 | | - #access plus 1 month | 1 year | 5 seconds | 2 days |
56 | | - <ifModule mod_expires.c> |
57 | | - ExpiresActive On |
58 | | - ExpiresByType text/html "access plus 600 seconds" |
59 | | - ExpiresByType application/xhtml+xml "access plus 600 seconds" |
60 | | - ExpiresByType image/gif "access 1 year" |
61 | | - ExpiresByType image/png "access 1 year" |
62 | | - ExpiresByType image/jpg "access 1 year" |
63 | | - ExpiresByType image/jpeg "access 1 year" |
64 | | - ExpiresByType image/x-icon "access 1 year" |
65 | | - ExpiresByType image/svg+xml "access plus 1 year" |
66 | | - ExpiresByType audio/ogg "access plus 1 year" |
67 | | - ExpiresByType video/mp4 "access plus 1 year" |
68 | | - ExpiresByType video/ogg "access plus 1 year" |
69 | | - ExpiresByType video/webm "access plus 1 year" |
70 | | - ExpiresByType application/atom+xml "access plus 1 hour" |
71 | | - ExpiresByType application/rss+xml "access plus 1 hour" |
72 | | - ExpiresByType application/pdf "access plus 1 month" |
73 | | - ExpiresByType text/css "access 1 month" |
74 | | - ExpiresByType application/javascript "access 1 month" |
75 | | - ExpiresByType text/x-javascript "access 1 month" |
76 | | - ExpiresByType text/x-component "access plus 1 month" |
77 | | - ExpiresByType application/x-shockwave-flash "access 1 month" |
78 | | - ExpiresByType font/opentype "access plus 1 month" |
79 | | - ExpiresByType application/vnd.ms-fontobject "access plus 1 month" |
80 | | - ExpiresByType application/x-font-ttf "access plus 1 month" |
81 | | - ExpiresByType application/font-woff "access plus 1 month" |
82 | | - ExpiresByType application/font-woff2 "access plus 1 month" |
83 | | - ExpiresDefault "access plus 30 days" |
84 | | - </ifModule> |
| 13 | + # Define additional rules below |
| 14 | + # |
85 | 15 |
|
86 | | - # BEGIN Cache-Control Headers |
87 | | - # public | private | must-revalidate |
88 | | - # Header set Cache-Control "private, must-revalidate" |
89 | | - # Header set Cache-Control "max-age=2592000, private" |
| 16 | + |
| 17 | + # Cache control headers |
90 | 18 | <IfModule mod_headers.c> |
91 | | - Header set Connection keep-alive |
92 | 19 | <filesMatch ".(js|css|xml|gz|html|php)$"> |
93 | 20 | Header append Vary: Accept-Encoding |
94 | 21 | </filesMatch> |
95 | | - <filesmatch "\.(ico|flv|gif|swf|eot|woff|otf|ttf|svg)$"> |
| 22 | + <filesMatch "\.(ico|flv|gif|swf|eot|woff|otf|ttf|svg)$"> |
| 23 | + Header set Cache-Control "max-age=31536000, public" |
| 24 | + </filesMatch> |
| 25 | + <filesMatch "\.(jpg|jpeg|png)$"> |
96 | 26 | Header set Cache-Control "max-age=31536000, public" |
97 | | - </filesmatch> |
98 | | - <filesmatch "\.(jpg|jpeg|png)$"> |
99 | | - Header set Cache-Control "max-age=31536000, public" |
100 | | - </filesmatch> |
101 | | - <filesmatch "\.(css)$"> |
102 | | - Header set Cache-Control "max-age=2592000, private" |
103 | | - </filesmatch> |
104 | | - <filesmatch "\.(js)$"> |
105 | | - Header set Cache-Control "max-age=2592000, private" |
106 | | - </filesmatch> |
107 | | - <filesMatch "\.(x?html?|php)$"> |
| 27 | + </filesMatch> |
| 28 | + <filesMatch "\.(css)$"> |
108 | 29 | Header set Cache-Control "max-age=2592000, public" |
109 | 30 | </filesMatch> |
| 31 | + <filesMatch "\.(js)$"> |
| 32 | + Header set Cache-Control "max-age=2592000, public" |
| 33 | + </filesMatch> |
| 34 | + <filesMatch "\.(x?html?)$"> |
| 35 | + Header set Cache-Control "public, must-revalidate" |
| 36 | + </filesMatch> |
| 37 | + <filesMatch "\.(x?php)$"> |
| 38 | + Header set Cache-Control "private, must-revalidate" |
| 39 | + </filesMatch> |
| 40 | + |
| 41 | + # Disable caching for PHP files when NO_CACHE is defined |
| 42 | + <IfDefine NO_CACHE> |
| 43 | + <FilesMatch "\.php$"> |
| 44 | + Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0" |
| 45 | + Header set Pragma "no-cache" |
| 46 | + Header set Expires "Thu, 01 Jan 1970 00:00:00 GMT" |
| 47 | + </FilesMatch> |
| 48 | + </IfDefine> |
110 | 49 | </IfModule> |
111 | | - |
| 50 | + |
112 | 51 | # Mod security |
113 | 52 | <IfModule mod_security.c> |
114 | 53 | SecFilterScanPOST Off |
115 | 54 | </IfModule> |
116 | | - |
| 55 | + |
117 | 56 | # Mod Speling |
118 | 57 | <IfModule mod_speling.c> |
119 | 58 | CheckCaseOnly On |
120 | 59 | CheckSpelling On |
121 | 60 | </IfModule> |
122 | | - |
123 | | - # Start Engine |
124 | | - RewriteEngine On |
| 61 | +</IfModule> |
125 | 62 |
|
126 | | - |
| 63 | +<IfModule mod_expires.c> |
| 64 | + # Set expiration for different file types |
| 65 | + ExpiresActive On |
| 66 | + ExpiresByType text/html "access plus 600 seconds" |
| 67 | + ExpiresByType application/xhtml+xml "access plus 600 seconds" |
| 68 | + ExpiresByType image/gif "access plus 1 year" |
| 69 | + ExpiresByType image/png "access plus 1 year" |
| 70 | + ExpiresByType image/jpg "access plus 1 year" |
| 71 | + ExpiresByType image/jpeg "access plus 1 year" |
| 72 | + ExpiresByType image/x-icon "access plus 1 year" |
| 73 | + ExpiresByType image/svg+xml "access plus 1 year" |
| 74 | + ExpiresByType audio/ogg "access plus 1 year" |
| 75 | + ExpiresByType video/mp4 "access plus 1 year" |
| 76 | + ExpiresByType video/ogg "access plus 1 year" |
| 77 | + ExpiresByType video/webm "access plus 1 year" |
| 78 | + ExpiresByType application/atom+xml "access plus 1 hour" |
| 79 | + ExpiresByType application/rss+xml "access plus 1 hour" |
| 80 | + ExpiresByType application/pdf "access plus 1 month" |
| 81 | + ExpiresByType text/css "access 1 month" |
| 82 | + ExpiresByType application/javascript "access 1 month" |
| 83 | + ExpiresByType text/x-javascript "access 1 month" |
| 84 | + ExpiresByType text/x-component "access plus 1 month" |
| 85 | + ExpiresByType application/x-shockwave-flash "access 1 month" |
| 86 | + ExpiresByType font/opentype "access plus 1 month" |
| 87 | + ExpiresByType application/vnd.ms-fontobject "access plus 1 month" |
| 88 | + ExpiresByType application/x-font-ttf "access plus 1 month" |
| 89 | + ExpiresByType application/font-woff "access plus 1 month" |
| 90 | + ExpiresByType application/font-woff2 "access plus 1 month" |
| 91 | + ExpiresDefault "access plus 30 days" |
| 92 | +</IfModule> |
| 93 | + |
| 94 | +<IfModule mod_gzip.c> |
| 95 | + # Enable gzip compression for resources |
| 96 | + mod_gzip_on Yes |
| 97 | + mod_gzip_dechunk Yes |
| 98 | + mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ |
| 99 | + mod_gzip_item_include handler ^application/x-httpd-php |
| 100 | + mod_gzip_item_include mime ^application/javascript$ |
| 101 | + mod_gzip_item_include mime ^application/x-javascript$ |
| 102 | + mod_gzip_item_include mime ^text/.* |
| 103 | + mod_gzip_item_exclude mime ^image/.* |
| 104 | + mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* |
| 105 | +</IfModule> |
| 106 | + |
| 107 | +<IfModule pagespeed_module> |
| 108 | + # Page Speed |
| 109 | + ModPagespeed on |
| 110 | + ModPagespeedEnableFilters rewrite_css,combine_css |
| 111 | + ModPagespeedEnableFilters recompress_images |
| 112 | + ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp |
| 113 | + ModPagespeedEnableFilters collapse_whitespace,remove_comments |
127 | 114 | </IfModule> |
0 commit comments