Answer the question
In order to leave comments, you need to log in
I wrote a website html/css/js, put it on hosting, what about caching?
I wrote the site, uploaded it to the hosting, checked it on PageSpeed Insights, saw that I needed to enable caching, I was told that caching is done manually VERY hard and advised to put the site on the WordPress engine and install the plugin, but no matter how the site was thought about it. But I installed , connected the plugin, but the site is not cached. Then I read about connecting caching to the site on html / css, it turned out that everything is easy to do there through .htaccess.
The question is, can I just upload my layout to the hosting, configure caching via .htaccess and that's it? Will the site work and there will be no problems/difficulties in the future?
Answer the question
In order to leave comments, you need to log in
Add this to htaccess:
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</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 mime ^text\.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_include mime ^application/javascript.*
mod_gzip_item_exclude mime ^image\.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access 7 days"
ExpiresByType image/x-icon "access plus 6 month"
ExpiresByType image/jpeg "access plus 6 month"
ExpiresByType image/jpg "access plus 6 month"
ExpiresByType image/png "access plus 6 month"
ExpiresByType image/gif "access plus 6 month"
ExpiresByType application/x-shockwave-flash "access plus 6 month"
ExpiresByType text/css "access plus 7504800 seconds"
ExpiresByType text/javascript "access plus 7516000 seconds"
ExpiresByType application/javascript "access plus 7516000 seconds"
ExpiresByType application/x-javascript "access plus 7516000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
The question is, can I just upload my layout to the hosting, configure caching via .htaccess and that's it? the site will work and there will be no problems/difficulties in the future?
advised to put the site on the wordpress engine
The website is html/css/js files? Just put it on the hosting, the web server will cache everything
Don't listen to anyone's advice!
1. Read about caching yourself
2. Adjust according to the documentation
3. Check with Google PageSpeed Insights .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question