WP Manifestindependent plugin directory
manifest / performance / cache-http-response

Cache HTTP Response.

Performance tweaks for WordPress to cache HTTP API Call response.

★ 2stars
12release downloads
v1.0.0latest · 4 years ago

Install

Download cache-http-response.zip From the v1.0.0 release on GitHub, Oct 13, 2022

Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/nawawi/cache-http-response/releases/download/v1.0.0/cache-http-response.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Performance tweaks for WordPress to cache HTTP API Call response.

Description

Performance tweaks for WordPress to cache WordPress API Call responses made by other plugins. This will reduce HTTP requests to external hosts if the plugin does not implement caching on their API calls.

Installation

Manual Installation

  1. Download the plugin zip file and save it as cache-http-response.zip.
  2. Upload and install the plugin zip file cache-http-response.zip through the WordPress plugins screen directly.
  3. Activate the plugin through the ‘Plugins’ screen in WordPress.

Via WP-CLI

WP-CLI is the official command-line interface for WordPress. You can install cache-http-response using the wp command like this:

wp plugin install --activate https://github.com/nawawi/cache-http-response/archive/main.zip

Update via WP-CLI

wp plugin install --activate https://github.com/nawawi/cache-http-response/archive/main.zip --force

Automatic Updates

Cache HTTP Response supports the GitHub Updater plugin WordPress. The plugin enables automatic updates from this GitHub Repository. You will find all information about the how and why at the plugin wiki page.

Settings

This plugin behaviour can be changed using a filter hook. You may load it as a 'mu-plugins' script. Copy this code and place it in wp-content/mu-plugins/cache-http-response-hook.php.

<?php
add_filter(
    'cache_http_reponse/ttl',
    function() {
        // 1 hour.
        return 3600;
    }
);

add_filter(
    'cache_http_reponse/include',
    function($urls) {
        //$urls[] = '';

        return $urls;
    }
);

add_filter(
    'cache_http_reponse/exclude',
    function($urls) {
        //$urls[] = '';

        return $urls;
    }
);

Filter Hooks

cache_http_reponse/include

By default, it will cache all URL if no URL apply to this filter.

add_filter(
    'cache_http_reponse/include',
    function($urls) {
        $urls[] = 'https://apihostname1.name/api';
        $urls[] = 'https://apihostname2.name/api';

        return $urls;
    }
);

cache_http_reponse/exclude

Exclude URL from the cache.

add_filter(
    'cache_http_reponse/exclude',
    function($urls) {
        $urls[] = 'https://apihostname1.name/api';
        $urls[] = 'https://apihostname2.name/api';

        return $urls;
    }
);

cache_http_reponse/ttl

Cache lifespan in seconds. By default, it is set to 300 seconds.

add_filter(
    'cache_http_reponse/ttl',
    function() {
        return 300;
    }
);

cache_http_reponse/exclude_wporg

Exclude *.wordpress.org URL. By default it is set to true.

add_filter(
    'cache_http_reponse/exclude_wporg',
    '__return_true'
);

cache_http_reponse/exclude_localhost

Exclude Site URL. By default it is set to true.

add_filter(
    'cache_http_reponse/exclude_localhost',
    '__return_true'
);

Changelog

1.0.0

  • Initial release.

Releases

1 release. Each count is every asset in that release; expand a row for the breakdown.

Tag
Published
Assets
Downloads
v1.0.0 latest
Oct 13, 2022 4 years ago
cache-http-response.zip
12