https://github.com/oliverfindl/wp-cache
[POC] Simple cache script for WordPress CMS based on Memcached. Script also includes simple quota mechanism.
https://github.com/oliverfindl/wp-cache
cache cms memcached php php7 script wordpress wp-cache
Last synced: 10 months ago
JSON representation
[POC] Simple cache script for WordPress CMS based on Memcached. Script also includes simple quota mechanism.
- Host: GitHub
- URL: https://github.com/oliverfindl/wp-cache
- Owner: oliverfindl
- License: mit
- Created: 2019-02-10T19:29:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-13T10:12:32.000Z (almost 7 years ago)
- Last Synced: 2025-02-07T08:49:04.537Z (12 months ago)
- Topics: cache, cms, memcached, php, php7, script, wordpress, wp-cache
- Language: PHP
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wp-cache

[](https://paypal.me/oliverfindl)
Simple cache script for [WordPress][WP] CMS based on [Memcached][MC]. Script also includes simple quota mechanism.
> This script is proof of concept. Never was used in production.
---
## Usage
If you completed the [installation](#install) and [setup](#setup) process, you should see new HTTP header called X-Cache-Status for each request telling you, if script is serving cached version or not. Additionally you get generation time displayed in comment at end of document. Cache is automatically turned off for logged users.
## Requirements
* [PHP 7][PHP-7]
* [PHP Memcached extension][PHP-MC-EXT]
* [Memcached][MC]
* [WordPress][WP]
## Install
```bash
# change directory to wp root
$ cd /path/to/your/wp-root
# clone this repo
$ git clone https://github.com/oliverfindl/wp-cache.git wp-cache-temp
# [optional] backup original .htaccess file if available
$ mv .htaccess .htaccess.bak
# copy wp-cache files from repo to wp root
$ cp wp-cache-temp/src/{.htaccess,wp-cache.php} .
# delete repo
$ rm -r wp-cache-temp
```
## Setup
```bash
# update rewrite base to wp root
$ vim .htaccess
# set preferred options in wp-cache.php file
$ vim wp-cache.php
```
## Options
```php
define("WP_INDEX_PATH", __DIR__ . "/index.php"); // path to index.php file
define("WP_LOAD_PATH", __DIR__ . "/wp-load.php"); // path to wp-load.php file
define("QUOTA_ENABLE", false); // enable quota, format: true|false
define("QUOTA_PERIOD", 60); // value in seconds, format: integer
define("QUOTA_LIMIT", 60); // number of requests per QUOTA_PERIOD, format: integer
define("CACHE_ENABLE", true); // enable cache, format: true|false
define("CACHE_PERIOD", 5 * 60); // value in seconds, format: integer
define("CACHE_SERVERS", [ // array of memcached server configs, format: [ [ host, port ], ... ]
["127.0.0.1", 11211],
// ["mc0.example.com", 11211],
// ["mc1.example.com", 11211],
// ...
]);
```
## Uninstall
```bash
# change directory to wp root
$ cd /path/to/your/wp-root
# remove wp-cache files
$ rm {.htaccess,wp-cache.php}
# [optional] restore .htaccess file from backup if available
$ mv .htaccess.bak .htaccess
```
---
## License
[MIT](http://opensource.org/licenses/MIT)
[WP]: https://wordpress.org/
[MC]: https://www.memcached.org/
[PHP-7]: https://secure.php.net/manual/en/install.php
[PHP-MC-EXT]: https://secure.php.net/manual/en/book.memcached.php