search
Log In
Welcome to BlogiesTools Ask, a platform where beginners and professional bloggers come to seek answers from other bloggers’ experiences.

You can register and login to ask or answer a question or do it anonymously without logging in.

You can ask questions related to starting a blog, monetizing a blog, marketing a blog, managing a blog, fixing a problem, best tools to use, etc.

Ask a Question

1 vote
How do I add expires HTTP headers to my WordPress blog without using a plugin
in Blog Optimization

1 Answer

0 votes
 
Best answer

To add expires headers in your WordPress blog without using a plugin 

  • Go to the .htaccess file (it is normally located in the public.html folder) or if you are using the Yoast SEO plugin access the .htaccess file from WordPress admin via Yoast>Tools>file editor>.htaccess file 
  • Copy and paste the expire headers code below the .htaccess file


# EXPIRES HEADERS START

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/webp "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/xhtml-xml "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>

# END EXPIRES HEADERS

  • Save changes  

What are expires headers? Expires headers is an HTTP header directive that tells a browser to download and store a web page's resources to the site visitor’s local computer browser for a set time. It also instructs the browser after how long the stored resources should be updated.

For example, if you visit a Facebook page for the first time, cached resources like (images, CSS, and JavaScript files) will be downloaded and stored in your local computer's browser. The next time you visit the same page, the resources will not be downloaded again from the page but will be loaded from the browser you used. This increases page load speed and saves data usage.

If you have files that frequently change, then it is advisable to reduce cache time or ignore browser cache. For example, HTML files.

11.7k points

Related questions

0 votes
1 answer
There is a blog that is displaying several of my images in their pages and it is affecting my bandwidth and site speed
asked Oct 30 in General anonymous
0 votes
1 answer
I need a code to change WooCommerce add cart button text without installing a plugin
asked Nov 8 in WordPress Problems anonymous
0 votes
1 answer
I have created a privacy page but I do not know how to add it in the footer section of my WordPress powered blog
asked Nov 3 in WordPress Problems anonymous
0 votes
1 answer
I have several posts on my WordPress site but I want to add CSS to a specific post, how do I do
asked Nov 3 in WordPress Problems anonymous
0 votes
1 answer
How do i optimize my blog post images in WordPress
asked Nov 18 in Blog Optimization anonymous