Skip to content Skip to sidebar Skip to footer

Can Comet Cache Add Etag Headers for Wordpress?

How To: WordPress Browser Caching

WP Engine Customers do non demand a browser caching plugin, we handle it on the server side which is far more than efficient than using a plugin based caching solution!


Browser caching is a sore discipline among many WordPress developers. Caching in your end-user's web browser is hard to come across and fifty-fifty harder to control at times, even so it can affect their unabridged experience.

What'south more, folio performance testing volition often instruct developers to "leverage browser caching", and this makes the problem more complex. How can developers leverage browser caching when they barely understand information technology?

In this guide we will explain what browser caching is, how it works, and the ways you can manipulate it on your WordPress website.

What is Browser Caching?

Simply put, browser caching is when your web browser stores a re-create of your spider web page, or elements within that page (like images, Cascading Style Sheet (CSS), and JavaScript files) on your local car. That way, the browser can bring up those files more than speedily the adjacent time they are requested.

This is great, considering it means a faster experience for returning users on your website. Even so, it can mean that the browser enshroud might hold on to elements of your site for longer than you'd like.

For example, what if you replace an image with a new one that has the same name? How will the spider web browser know to load the new image? How many users are getting the old ane? These are all questions developers struggle to answer when it comes to browser caching.

What Does It Mean to Leverage Browser Caching?

When you leverage browser caching, you lot're taking full advantage of this technology to speed up your page loading times. This means tailoring the caching's configuration to tell browsers how long they should retain certain website files. Every bit a result, users' browsers should be able to load the saved versions of your pages much faster than if they had to asking them from your server once again. However, the enshroud tin be updated frequently plenty to avoid showing former content to users.

Nosotros'll embrace several different means to exercise this before long. Typically, in order to  leverage browser caching,  you'll need to edit some of your website files. Regardless of the method, however, your goal is to specify the storage duration and enshroud behavior for specific file types.

How Does Leveraging Browser Caching Speed Up WordPress?

When you visit a website, clicking on a link or typing in a web accost initiates a call to that site's server. The server gets the telephone call, retrieves the necessary data (which can include images, coded files like HTML and CSS, so on) and sends them out to be displayed for the user.
While this usually takes moments, a delay of just two or three seconds puts y'all at chance of losing traffic. Fortunately, browser caching can improve page speeds for WordPress websites.

Browser Caching on WP Engine

With WP Engine, our robust caching layers mean your site is very cacheable, making it speedier for your users. Our web servers add headers to your website, telling it how long to enshroud each page:

By default, web pages are cached for ten minutes (600 seconds), and static resources like your images, JavaScript, and CSS files are cached for 30 days (equally they rarely change).

Web browsers respect the headers nosotros set up for our server-level caching. This means they volition likewise enshroud pages for ten minutes, and static resources for 30 days.

Leverage Browser Caching by Editing Your .htaccess File

If you aren't hosting your website with WP Engine, but you lot are using Apache (ane of the recommended servers for WordPress) you can manually manage your browser cache settings. This is accomplished by configuring a header in your website'due south .htaccess file.

.htaccess is a configuration file that contains important directives for your WordPress server. To access it, you'll need to use a File Transfer Protocol (FTP) application such as FileZilla or CuteFTP.

If your host offers Secure FTP (SFTP) access, it's all-time to use that to locate and edit the file in the root directory of your WordPress website. Since the file name begins with a flow, yous may take to enable hidden files in your FTP/SFTP customer.

Editing this file direct offers more granular control to developers who want to leverage browser caching, simply don't want to be constrained by limited plugin options. To get you started, permit's walk through the iii steps in the process.

Expire headers involve a snippet of code that tells your server when a cache duration is set to expire for specific file types. Essentially, you lot're setting the expiration date for the enshroud storage.

One time you locate the .htaccess file, you can add the following expires header code:

          ## EXPIRES CACHING ##  ExpiresActive On  ## EXPIRES CACHING ##        

This turns on the expires header, and enables you to add instructions for each of the file types yous want to extend the cache elapsing for.

For instance, if you lot want all image files with a .jpg extension to remain cached for one month from the date of a user's concluding browser admission, y'all can add the post-obit lawmaking to the line below the "On" control:

          ExpiresByType paradigm/jpg "access plus 1 month"        

You lot'll need to repeat the "ExpiresByType" directive for every file type you want to cache. Each type should be on a separate line. So y'all tin can add the following lawmaking at the end before you shut out, to ready a default cache for anything that slips through the cracks:

          ExpiresDefault "access plus 2 days"        

This represents a basic expire headers lawmaking. It'southward of import to notation that this is a somewhat dated approach to leveraging browser caching. Nevertheless, it's okay to pair it with our next method, equally long as you practise not set conflicting expiration parameters.

Cache-Control is a directive used for both requests and responses in the browser. In social club to create a valid cache-command header, in that location are a few rules you lot'll need to follow:

  • Directives are case-sensitive, but information technology's recommended that you use all lowercase messages.
  • Utilise commas to split multiple directives.
  • Certain directives accept either token or quoted-string optional arguments.

With this directive, you can set different rules for diverse file types. If yous ever desire .html and .php files to be revalidated and never cached, for example, you can use cache-control to do and then. The post-obit are examples of cache-command request directives:

          Cache-Control: max-age=<seconds> Cache-Control: max-dried[=<seconds>] Enshroud-Control: min-fresh=<seconds> Cache-Control: no-enshroud  Cache-Control: no-shop Enshroud-Command: no-transform Cache-Control: but-if-cached        

Note that the unit of time is configured in seconds. In our example above, the "max-age" has been set up to x minutes (or 600 seconds). If you wanted to set the expiration at four hours, y'all would replace that number with "14400".

By using both the asking and responsive directives, y'all can configure how you desire all of your website's files to reply to user activity. This means you can exclude items like your wp-admin files from caching, as yous'll ever desire to take access to the most recent versions from your server.

An Entity Tag (ETag) is a response header used to identify or 'tag' unlike versions of your website's files. ETags enable the native browser cache to be more efficient and effective.

This technique helps to cut down on unnecessary revalidation by the server, by identifying files that have not changed and don't need to be refreshed. ETags are assigned whenever a resource file for a given URL changes. The tags are then used for comparison, to see if at that place are differences between the former and new versions.

Since you've just added expires and enshroud-control headers to your .htaccess file, still, you don't really need ETag to practice its job anymore. To avoid conflicts, it'southward all-time to disable this header. Y'all can do then by adding the following code later on your cache-control header:

          Header unset ETag FileETag None        

This forces browsers to rely on the enshroud-control and expires headers yous've already configured.

Server Configuration

If you are not using Apache to run WordPress, it's likely yous might be using Nginx. This is the other server that is recommended by WordPress. In this case, y'all still take some command over how long your files are cached by the browser.

However, you lot'll need to do some server configuration kickoff. If yous're not familiar with Nginx, this volition require using Terminal to execute instructions and changes through the command line.

Leverage Browser Caching on NGINX Servers

Your first pace is to check your electric current cache settings. You lot tin do that by sending a request in Terminal to an prototype file on your website. You lot should receive the header information in render.

If you decide you want to make adjustments to your cache settings, you tin can outset with the post-obit two directives to enable basic caching with Nginx:

  • Proxy_cache_path
  • Proxy_cache

The first directive is how you'll set the path and configuration for the cache, and the second directive is what activates the new caching rules.
Nginx also has an in-depth guide bachelor for more ways to heighten your cache options. It includes directives for establishing shared memory zones for storing cache keys, and much more than.

Leverage Browser Caching with WordPress Browser Caching Plugins

When hosting on WP Engine, our caching layers take care of cumbersome configurations and fine-tuning on your behalf. Additionally, if you desire to customize how long your pages are cached for, you lot tin can utilise our WP Engine Avant-garde Cache plugin.

While you lot cannot decrease the default ten minute cache, you can increase and customize information technology to meet your site's needs. If y'all exercise non host with WP Engine, you can use one of the post-obit WordPress plugins to set and configure caching settings.


You practise not demand a caching plugin if you are on WP Engine, nosotros handle it for yous more efficiently on the server side!


W3 Total Enshroud

The W3 Total Cache plugin is one of the most-widely used caching plugins in the WordPress.org repository.

Pros: Not only does this plugin assistance users easily configure server and browser caching preferences, it too offers cacheability statistics for performance insights, and offers minification of static resources for faster admission.

Cons: Finding the correct configuration to optimize performance but not conflict with developer workflows can exist a struggle. There are many configuration options, which can be confusing for less advanced users.

Note: This is on our disallowed plugins list, since it conflicts with and duplicates our server-side caching engineering science.

WP Super Cache

WP Super Cache uses the aforementioned style of directives that you can fix manually in your configuration files, and has a wide user base.

Pros: Unlike W3 Total Enshroud, WP Super Cache offers the power to get granular most which users become cached pages and which don't, with only a few simple configuration options for ease of utilise.

Cons: WP Super Cache stores a static file copy of each page on your web server as it is cached. While it offers a 'cleanup' choice to periodically clean out your buried files, this tin can bulk up your storage chop-chop.

Note: This is on our disallowed plugins list, since it conflicts with and duplicates our server-side caching technology.

WP Rocket

WP Rocket WordPress plugin

A premium plugin, WP Rocket offers paid licensing at the single site, three-site, and unlimited website-per-yr levels.

Pros: This plugin can be used in conjunction with WP Engine'southward caching layers, and offers preloading of content and lazy-loading for images with minimal manual configuration needed.

Cons: WP Rocket also stores static files on the web server, which can clutter your web server storage infinite. Some users have also institute the pre-congenital options to be limiting, and take developed actress add together-on plugins to add together the functionality they need.

WP Fastest Enshroud

While WP Fastest Cache doesn't have quite equally many downloads as the other options on our list, over 500,000 users have given it a solid 5-star rating.

Pros: Apply of this plugin is very uncomplicated, as it automatically edits the .htaccess file on your behalf. Pages and posts can be excluded from the cache by using a shortcode. It also works for browser caching, minification, and compression.

Cons: WP Fastest Cache besides stores files on the web server, which can bulk up your disk infinite usage. It is also not compatible with multisite.

Annotation: This is on our disallowed plugins listing, since it conflicts with and duplicates our server-side caching technology.

Leverage Browser Caching

The Leverage Browser Caching plugin is a straightforward, free tool. Its main focus is to amend your page speeds, by establishing amend browser caching for your website's files.

Pros: This an easy-to-use plugin. It adds expire headers directives directly into your .htaccess file, then you don't have to detect and edit the lawmaking yourself.

Cons: There is no settings interface for this plugin. Once you install information technology, the header will be automatically added to your file. Additionally, there is no way to know what the default cache settings are unless you lot expect them up in your .htaccess file.

Note: This is not on our disallowed plugins listing. However, it's best to bank check with our support technicians before you install it. Its essential features may duplicate or conflict with our server-side caching technology.

Why WP Engine for Caching?

The WP Engine platform compages is finely-tuned to provide the best website performance and highest cacheability. This means your website volition be more agile when floods of traffic come to your website, while still responding rapidly.

Our intelligent traffic shaping system likewise ensures that fifty-fifty highly-uncacheable sites will stay up nether high-traffic conditions. Prepare to dive in? Check out our WP Engine hosting plans!

lindseymulend72.blogspot.com

Source: https://wpengine.com/resources/wordpress-browser-caching/

Postar um comentário for "Can Comet Cache Add Etag Headers for Wordpress?"