Download This Plugin | |
Download Elegant Themes | |
Name | Add Headers |
Version | 1.2.0 |
Author | George Notaras |
Rating | 100 |
Last updated | 2015-01-08 12:29:00 |
Downloads |
5018
|
Download Plugins Speed Test plugin for Wordpress |
Home page PageSpeed score has been degraded by 0%, while Post page PageSpeed score has been degraded by 0%
Add Headers plugin added 132 bytes of resources to the Home page and 132 bytes of resources to the sample Post page.
Add Headers plugin added 0 new host(s) to the Home page and 0 new host(s) to the sample Post page.
Great! Add Headers plugin ads no tables to your Wordpress blog database.Adds the ETag, Last-Modified, Expires and Cache-Control headers to HTTP responses generated by WordPress for more efficient caching.
Add-Headers gives you control over the ETag, Last-Modified, Expires and Cache-Control HTTP headers which your WordPress powered website sends back to the clients when dynamic pages are requested. This results in more efficient caching, reduction of bandwidth consumption and server load.
The aforementioned HTTP headers are sent to the client when visiting the page of a post, page, attachment, custom post type, the front page (static pages are supported) or a page of a category, tag, custom taxonomy, author or date based archive (pagination is supported). All feeds (posts feed, comments feed, post comments feed, archive feeds) are supported. Search results pages are supported, but no caching is permitted by default.
The value of each header is based on information provided by the post object in each of the above pages.
In case of archives, the first post is used in order to determine the time
the archive was last modified. It is possible to customize this by utilizing
the addh_archive_post
filter (see below). Special consideration has been
taken so that ETags are unique, even if a post appears first in more than one archives.
In case of feeds, the ETag and the Last-Modified headers are generated by WordPress itself. Add-Headers adds the Expires and Cache-Control headers to the feeds.
By default, the expiration date of each page is set to one day (86400 seconds) after the time the client accessed the resource, but this is configurable (see configuration section).
In addition to the Cache-Control header, the plugin also sets the Pragma
header to cache
or no-cache
according to the defined max-age
of the
Cache-Control header.
Add-Headers is released under the terms of the GNU General Public License version 3 and, therefore, is Free Software.
However, a significant amount of time and energy has been put into developing and testing this plugin, so, its production has not been free from cost. If you find this plugin useful and if it has helped your blog pages get cached more efficiently and has saved you bandwidth and CPU load, you can show your appreciation by making a small donation.
Donations in the following crypto currencies are also accepted and welcome. Send coins to the following addresses:
1KkgpmaBKqQVk643VRhFRkL19Bbci4Mwn9
LS8UF39LfLahzGo49y736ooRYBVT1zZ2Fa
Thank you in advance for donating!
The plugin can be configured by filtering the options array. You can add a
filtering function like the following in the functions.php
file of your theme:
function addh_custom_options ( $options ) {
// These are the default options.
return array_merge( $options, array(
'add_etag_header' => true,
'generate_weak_etag' => false,
'add_last_modified_header' => true,
'add_expires_header' => true,
'add_cache_control_header' => true,
'cache_max_age_seconds' => 86400,
'cache_max_age_seconds_for_search_results' => 0,
'cache_max_age_seconds_for_authenticated_users' => 0,
) );
}
add_filter( 'addh_options', 'addh_custom_options', 10, 1 );
The settings above demonstrate the default values.
By setting any of the max-age settings to 0
, a Cache-Control: no-cache, must-revalidate, max-age=0
header is sent. cache_max_age_seconds_for_search_results
only affects search
results. cache_max_age_seconds
affects all pages. If you need more customization,
it is possible to filter the headers before they are sent to the client (see Available Filters section).
The rest of the options should be self-explanatory.
The following filters can be used to further customize the HTTP headers.
addh_options
addh_cache_control_header_format
Cache-Control
header's value. The hooked function should accept and return 1 argument: a string. The default template is "public, max-age=%s
". The template must have one %s
placeholder for the max-age seconds.addh_headers
addh_headers_feed
addh_archive_post
addh_supported_post_types_singular
is_singular()
is true. By default, regular posts, pages, attachments and public custom post types are supported. The hooked function should accept and return 1 argument: an array of post types.addh_supported_post_types_archive
is_archive()
is true. By default, regular posts and public custom post types are supported. The hooked function should accept and return 1 argument: an array of post types.You can use curl in order to check the headers.
For example:
curl -I -L http://example.org/sample-page/
curl -I -L -H "Accept-Encoding: gzip,deflate" http://example.org/sample-page/
curl -I -L -H "If-Modified-Since: Mon, 16 Dec 2013 10:10:00 GMT" http://example.org/sample-page/
curl -I -L -H "If-None-Match: \"abcdefghijklmn\"" http://example.org/sample-page/
The development takes place at:
https://bitbucket.org/gnotaras/wordpress-add-headers
Mirror:
https://github.com/gnotaras/wordpress-add-headers
Pull requests are welcome.
If you use Varnish, try the WPVM plugin to purge pages either automatically as they are updated or on demand.