This is just a quick post to quickly get you to improve your website’s speed if you are running an Apache web server.
Create a .htaccess file (if one isn’t already present) and add the following lines at the end of the file:
# Setting longer cache time
ExpiresByType text/css "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
For example, if you make a lot of changes to the CSS and images, you might prefer files to expire after a day, in which case you can change it to:
ExpiresByType text/css "now plus 1 day"
ExpiresByType can take in a number of keywords like: years, months, weeks, days, hours, etc. For more info, check out Alternative Interval Syntax for ExpiresByType.
If you have anything to add, feel free to drop it in the comments and I’ll update the post.