Answer the question
In order to leave comments, you need to log in
How to enable page caching?
Good afternoon.
You need to enable caching for the site.
I climbed hundreds of Google pages, different .htaccess are given everywhere
I tried everything! But still Google PageSpeed says that caching is not enabled
Code .htaccess
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
SetOutputFilter DEFLATE
Answer the question
In order to leave comments, you need to log in
Something like this:
# Заголовок Cache-Control
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
And what is the site spinning on? On apache? In fact, caching implies the presence of several HTTP headers, and then they need to be inserted either on the application side or forcedly in the http server. Do you have Apache? Then you can for example like this - httpd.apache.org/docs/current/mod/mod_expires.html
Cache-Control: max-age=3600, must-revalidate
Expires: Fri, 30 Oct 1998 14:19:41 GMT
Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT
ETag: "3e86-410-3596fbbc"
I also suffered for a long time, with the .htaccess file, until I wrote to the hosting support service. may be disabled by default.
Server:nginx answers me your site.
Torture better nginx, not apache. And it's better to torment in the direction of caching, not compression :)
And now it turns out that you are asked to change the oil, and you go and charge the battery.
either nginx on the host in the site settings, or disable it through Apache
<ifModule mod_expires.c>
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
# Compress compressible fonts
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
# Cache Images
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/svg+xml "access plus 2592000 seconds"
# Cache Fonts
ExpiresByType application/vnd.ms-fontobject "access plus 2592000 seconds"
ExpiresByType application/x-font-ttf "access plus 2592000 seconds"
ExpiresByType application/x-font-opentype "access plus 2592000 seconds"
ExpiresByType application/x-font-woff "access plus 2592000 seconds"
ExpiresByType image/svg+xml "access plus 2592000 seconds"
# Cache other content types (Flash, CSS, JS, HTML, XML)
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 2592000 seconds"
ExpiresByType application/javascript "access plus 2592000 seconds"
ExpiresByType application/x-javascript "access plus 2592000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question