Linkhub #51

Linkhub #50

Linkhub #49

Linkhub #48

Linkhub #47

yab_api_cache - Simple url cache for Textpattern CMS

I’ve written a simple url cache for Textpattern CMS. I use it for caching API content or shared static HTML from one source. It’s relativly straightforward.

You can grab it from GitHub. The compiled plugin version is located under the /dist folder.

yab_api_cache

Simple url cache.
Caches the outout of an url (simple GET APIs, URIs, websites etc.).
It can also be used to cache dynamic pages of the own website. Especially the ones with a lot of huge dynamic lists (but you can also use etc_cache parts of the site).

Version: 0.1.2

Table of contents

  1. Plugin requirements
  2. Configuration
  3. Tags
  4. Examples
  5. Changelog
  6. License
  7. Author contact

Plugin requirements

  • Textpattern >= 4.7.x

Configuration

Open the plugin code. The yab_api_cache function contains the configuration values. Can also be configured by tag attributes. See tag attribute for info.

Tags

yab_api_cache

This tag will output the content of a given url live or cached.

id: any valid string or empty
Default: not set
A valid string to identify the content, If not provided ist will be generated by md5 the utl attrbiute.

url: a valid string (URI)
Default: null
The URI which to be requested and shown

cached: integer|bool (1|0)
Default: true
If set to 0 (false) the requested content is live instead of the cached one.

cache_time: integer (seconds)
Default: 3600
Cache time in seconds

clear_cache: integer|bool (1|0)
Default: false
If set to 1 (truly) it will clear the entire cache.

Examples

Example: simplest

<txp:yab_api_cache url="https://exmaple.com/api/show/users" />

Shows the cached output of the given url. Renews the chache after 1 hour (3600 seconds). The md5 hash of the url is used as id.

Example: advanced

<txp:yab_api_cache id="my-api-call" url="https://exmaple.com/api/show/users" cache_time="86400" />

Shows the cached output of the given url. Renews the chache after 1 day (86400 seconds). An own id is privided

Example: no-cache

<txp:yab_api_cache id="my-api-call" url="https://exmaple.com/api/show/users" cached="0" />

Shows the live output of the given url. An own id is privided.

Example: reset

<txp:yab_api_cache clear_cache="1" />

Clears the entire cache (Empties the table).

Changelog

  • v0.1.2 – 2020-03-21
    • modified: add plugin help, public release
  • v0.1.1 – 2018-02-14
    • bugfix: id and url will be parsed
    • modifed: id not mandatory, will be created by url
  • v0.1.0 – 2017-10-29
    • initial release

Licence

This plugin is released under the GNU General Public License Version 2 and above

Author contact

Linkhub #46

| ältere Einträge