We continue today with the configuration of the browser cache and objects. The browser is part of the tools that optimize the loading of a website, this element should not be neglected.

For those who don't know, we perform a series of configuration on the W3TC or W3 Total Cache plugin, which is a cache plugin which will allow you to optimize the speed of your WordPress blog. During this series of tutorials, we have already developed several chapters in the configuration of the W3 Total Cache plugin.

You need to understand what we talked about in the previous episode about database configuration. We are going to talk in this tutorial about configuring object cache and browser cache.

1 - Object Cache

The menu " object cache "Has a single section of advanced settings.

SETTINGS-advances

The first two fields in this section to know " Default Lifetime of hidden objects " and " Garbage collection interval Are used to define the lifetime of the cache objects and the frequency with which the expired objects are deleted. You can decrease the life of objects or reduce the interval for deleting objects that have expired. Alternatively, if you want to decrease the load on the server, you can increase both values. In most cases, the default values ​​are acceptable.

The following fields, " Global Groups Is used to identify groups of objects that are shared between sites, when using a WordPress multisite network. The idea of ​​this feature is that some of these objects can be cached and reused across the network.

global-settings-w3tc-SETTINGS

You don't need to change the “Global Groups” settings unless you are an experienced WordPress developer and are familiar with how groups work.

Finally, the "Non-persistent groups" field is used to identify objects that should never be cached in the object cache. Again, unless you are familiar with object groups, do not edit this field.

2 - Browser cache

This menu has four sections for fine-tuning the browser cache: General, CSS and JS, HTML and XML, Media and Other Files. The fields presented in each section are almost identical. When you adjust the settings of the general section, these same settings will be applied to all subsequent sections. Then you can override the specific settings in the last sections after you are done with the configuration of the "General" section. Therefore, you should configure the “General” section first, and then fine-tune in each corresponding section if necessary.

Browser cache: General

The first four options in the " General Are all similar to each other. In essence, all four do the same thing: make the data stored in the cache always valid. However, each does it in a different way.

hide-the-browser-wordpress-w3tc

The options " Set Last-modified header "And" eTag "are stored by a browser and then used later to ask the server if there are new versions of the stored documents.

The options " Expires header " and " Set cache control header »Limit the lifetime of cached resources. Header expiration achieves this by assigning a fixed expiration date to the cached resources. While " Cache control header Is used to assign a lifetime that begins to run when the cached object is downloaded by the browser.

At least, activate the first option of " Set Last-Modified - header ". If you want to be more careful, by allowing your visitors to have the most up-to-date version of your site, activate the additional options.

Activate the option " Set W3 Total Cache header if you want to be able to look at a document's HTTP header to determine if it has been cached by W3TC. If you don't know how to watch HTTP headers or don't care, just leave this option disabled. This does not affect performance.

configuration-browser-w3tc-tutorial

Leave the option " Enable HTTP (gzip) compression Activated. This reduces the size of text files and can have a significant impact on site performance.

Leave the option " Prevent caching of objects after settings change Checked. This ensures that all time parameters are changed and a new string is generated and attached to all cached items so that browsers know how to get rid of old files to download the latest ones.

There are some website resources that you will not want to be cached by the browser. It could be a Flash media player. Add the path to these resources in the " Prevent caching exception list ».

Check the option " Do not set cookies for static files ».

Control-of-cookies-w3tc

The idea here is that static files (images, CSS and JavaScript files) do not need a cookie to be added to the HTTP header.

The next option "Do not process 404 errors for static objects with WordPress", will reduce the server load by allowing the server to handle static 404 files rather than using the default WordPress 404 process.

Unless you expect a heavy load of 404 pages, selecting this option or not won't change performance much. The best practice would be to check this option, but this may cause some plugins to generate a bunch of 404 errors. If this happens, you will need to manually add the URLs for the infringing resources to the field titled "404 error exception list. ".

Browser cache: CSS & JS, HTML & XML, media

Each of these sections will inherit values ​​added to the " General ". However, you can use each of these sections to refine how each type of resource is handled in the browser cache.

That's it for this tutorial. If you have any questions, feel free to ask them in the comments.