: How to enable browsing cache for my website? I have created a website and the speed of my website is very slow. i want to enable browser cache for my website how can i do this ?
I have created a website and the speed of my website is very slow. i want to enable browser cache for my website how can i do this ?
More posts by @Shakeerah822
2 Comments
Sorted by latest first Latest Oldest Best
When you connect to your FTP server, create .htaccess file and paste one of these codes in it:
Adding Expire Headers
ExpiresActive On
ExpiresDefault A0
# 1 YEAR - doesn't change often
<FilesMatch ".(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A31536000
</FilesMatch>
# 1 WEEK - possible to be changed, unlikely
<FilesMatch ".(jpg|jpeg|png|gif|swf)$">
ExpiresDefault A604800
</FilesMatch>
# 3 HOUR - core content, changes quickly
<FilesMatch ".(txt|xml|js|css)$">
ExpiresDefault A10800
</FilesMatch>
Using max-age headers
# 1 YEAR
<FilesMatch ".(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
# 1 WEEK
<FilesMatch ".(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 3 HOUR
<FilesMatch ".(txt|xml|js|css)$">
Header set Cache-Control "max-age=10800"
</FilesMatch>
# NEVER CACHE - notice the extra directives
<FilesMatch ".(html|htm|php|cgi|pl)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>
Both of these types cache files with the extension that is in parentheses "()".
You can change these file extensions if you feel some files are going to be edited more frequently. Don't forget to split them with the vertical bar "|"
You can check if your caching works on Redbot.org
More about HTTP caching here
Easiest way would be to use a CDN like Cloudflare. They will automatically cache your static resources, and serve them over HTTP2 as well if you want. This should have an immediate effect on the speed of your site.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.