How to Add Expires Headers in WordPress (2 Methods) – Website Tips

Curated by WorkingFromHome

This article is an excerpt from the original article found in the Read More link – please follow for full article.

Do you want to learn how to add expires headers in WordPress?

Expires headers are rules that let web browsers know whether to load a web page resource like images from the visitor’s browser cache or from your server. These can help improve the performance of your site.

In this article, we’ll show you two ways to add expires headers in WordPress.

How Are Expires Headers Used in WordPress?

The first time someone visits a web page on your WordPress site, all of the files are loaded one by one. All of these requests between the browser and your WordPress hosting server increase the web page loading time.

Browser caching stores some or all of those files on the visitor’s computer. That means that the next time they visit the page, the files can be loaded from their own computer, boosting your WordPress performance.

Now you might be wondering, how do the browsers know which files to save, and how long to keep them?

That’s where expires headers come in.

The rules about which files to save and how long to save them are set using either expires headers or cache-control headers. In this article, we’ll focus on expires headers because they’re simpler to set up for most users.

Expires headers set an expiration date for each type of file stored in the browser cache. After that date, the files will be reloaded from your server to give visitors the most recent version of the page.

We’ll show you how to add expires headers using two different methods. The first method is easier and recommended for most users. You can click the links below to jump ahead to your preferred section:

Method 1: Add Expires Headers with WP Rocket WordPress Plugin

WP Rocket is the most beginner-friendly WordPress caching plugin in the market. Once enabled, it works immediately to speed up your site without having to mess with complicated configuration settings like many other caching plugins.

WP Rocket is a premium plugin, but the best part is that all features are included in their lowest plan.

The first thing you need to do is install and activate the WP Rocket plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Once installed and activated, WP Rocket will automatically turn on browser caching. By default, it add expires headers and cache-control headers with the best settings to speed up your WordPress site.

That’s all you need to do. If you want to learn more about the plugin, then see our guide on how to properly install and setup WP Rocket in WordPress.

If you’d prefer to use a free caching plugin to add expires headers to your website, then we recommend you take a look at W3 Total Cache.

W3 Total Cache offers some of the same features as WP Rocket, but it’s not as beginner-friendly. You’d have to manually enable expires headers, since it doesn’t enable them automatically.

Method 2: Add Expires Headers in WordPress Using Code

The second method to add expires headers in WordPress involves adding code to your WordPress files. We don’t recommend it for beginners, since a mistake in the code could cause serious errors and break your site.

Before making these changes, we recommend that you first back up your WordPress site. For more details, see our guide on how to backup and restore your WordPress site.

With that said, let’s take a look at how to add expires headers by adding code to WordPress.

Determine if Your Website is Running Apache or Nginx

First, you need to figure out whether your website is using Apache or Nginx servers. To do this, browse to your website and right click the page, then select the ‘Inspect’ option.

Next, you need to click the ‘Network’ tab at the top of the page. You may need to refresh the page for the results to load.

After that, you can click your domain name at the top of the ‘Name’ column. Then you should scroll down to the ‘Response Headers’ section and check for an item called ‘server’.

This will show you which web server is being used. In this case, the site is running on an Nginx server.

Now that you know which web server your site is using, use then links below to jump ahead:

How to Add Expires Headers in Apache

To add expires headers to an Apache server, you need to add code to your .htaccess file.

To edit this file, you need to connect to your WordPress hosting account with an FTP client or your host’s file manager tool. You’ll find your .htaccess file in your website’s root folder

For the Full Article
You can Find it Here: How to Add Expires Headers in WordPress (2 Methods)

Commentary:
Quite handy tips and urls can be read on this full post.
source – WPBeginner.com

You May Also Like…

Welcome Easy Digital Downloads, WP Simple Pay, AffiliateWP, and More to the WPBeginner Family of Products – Website Tips

Welcome Easy Digital Downloads, WP Simple Pay, AffiliateWP, and More to the WPBeginner Family of Products – Website Tips

Today, I’m extremely excited to share that all Sandhills Development products are joining Awesome Motive, and they’re now part of the WPBeginner family of products. This includes several popular WordPress plugins including Easy Digital Downloads, AffiliateWP, WP Simple Pay, Sugar Calendar, and many more. These brands are very close to my heart because when I first started selling premium plugins in 2013, we used Easy Digital Downloads, and we still use EDD to power our eCommerce. This is one of those rare life moments where things have come full circle, and I honestly feel like I’m living in a dream. Introduction – Quick Overview of the Plugins Unlike our other investments, this is an acquisition of a large portfolio of plugins, so I’ll give a quick overview of what each of them do. Easy Digital Downloads makes it easy for you to sell digital products online such as eBooks, digital…

How to Set Up Business Call Forwarding From Your Website – Website Tips

How to Set Up Business Call Forwarding From Your Website – Website Tips

Do you want to set up business call forwarding from your website? For many small businesses, calls from potential customers generate significant sales and revenue. This is why it’s important to properly set up business call forwarding from your website. In this article, we will share a step by step guide on how to easily set up business call forwarding from your WordPress site. What Do You Need to Set Up Business Call Forwarding from Your Website? Normally, you can just add a phone number to your WordPress website or online store. Your website visitors can use the phone number to make a call. However, regular phone services don’t come with advanced features like call forwarding, business hours, call waiting, etc. Plus, they cost a lot more even for even basic features like basic call forwarding. For proper business call forwarding, you’ll need a smart business phone service provider. We…

Working From Home TV …

Tips to enhance your own website…

Welcome Easy Digital Downloads, WP Simple Pay, AffiliateWP, and More to the WPBeginner Family of Products – Website Tips

Welcome Easy Digital Downloads, WP Simple Pay, AffiliateWP, and More to the WPBeginner Family of Products – Website Tips

Today, I’m extremely excited to share that all Sandhills Development products are joining Awesome Motive, and they’re now part of the WPBeginner family of products. This includes several popular WordPress plugins including Easy Digital Downloads, AffiliateWP, WP Simple Pay, Sugar Calendar, and many more. These brands are very close to my heart because when I first started selling premium plugins in 2013, we used Easy Digital Downloads, and we still use EDD to power our eCommerce. This is one of those rare life moments where things have come full circle, and I honestly feel like I’m living in a dream. Introduction – Quick Overview of the Plugins Unlike our other investments, this is an acquisition of a large portfolio of plugins, so I’ll give a quick overview of what each of them do. Easy Digital Downloads makes it easy for you to sell digital products online such as eBooks, digital…

How to Set Up Business Call Forwarding From Your Website – Website Tips

How to Set Up Business Call Forwarding From Your Website – Website Tips

Do you want to set up business call forwarding from your website? For many small businesses, calls from potential customers generate significant sales and revenue. This is why it’s important to properly set up business call forwarding from your website. In this article, we will share a step by step guide on how to easily set up business call forwarding from your WordPress site. What Do You Need to Set Up Business Call Forwarding from Your Website? Normally, you can just add a phone number to your WordPress website or online store. Your website visitors can use the phone number to make a call. However, regular phone services don’t come with advanced features like call forwarding, business hours, call waiting, etc. Plus, they cost a lot more even for even basic features like basic call forwarding. For proper business call forwarding, you’ll need a smart business phone service provider. We…

How to Notify Subscribers of New Posts in WordPress (3 Ways) – Website Tips

How to Notify Subscribers of New Posts in WordPress (3 Ways) – Website Tips

Do you want to notify your website subscribers about new posts on your WordPress blog? Notifying your subscribers about new content helps you stay in touch with your visitors, bring them back to your website, and convert them into customers. In this article, we’ll show you how you can notify subscribers when new posts are published on your WordPress blog. Why Notify Subscribers of New Posts in WordPress? For most websites, nearly 70% of website visitors will never come back again. By notifying subscribers that you’ve published a new post, they’re likely to return to your WordPress website to read it. This lets you provide more value and deepen the relationship with your subscribers. For online stores, notifying subscribers of new posts will help you to turn those subscribers into loyal customers. That being said, let’s look at how you can notify subscribers of your new posts using a few…

0 Comments

Submit a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.