Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/szepeviktor/tiny-cache
🚄 Cache WordPress post content, template part, translations and nav menu output in persistent object cache
https://github.com/szepeviktor/tiny-cache
cache object-cache performance wordpress-plugin
Last synced: 28 days ago
JSON representation
🚄 Cache WordPress post content, template part, translations and nav menu output in persistent object cache
- Host: GitHub
- URL: https://github.com/szepeviktor/tiny-cache
- Owner: szepeviktor
- Created: 2017-06-28T10:03:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-21T19:09:36.000Z (almost 2 years ago)
- Last Synced: 2024-10-09T10:13:30.202Z (about 1 month ago)
- Topics: cache, object-cache, performance, wordpress-plugin
- Language: PHP
- Homepage: https://github.com/szepeviktor/wordpress-website-lifecycle/blob/master/WordPress-performance.md
- Size: 25.4 KB
- Stars: 27
- Watchers: 6
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-wp-speed-up - Tiny Cache - Cache post content, translations and nav menu output in persistent object cache. (Object Caching Plugins)
README
# Tiny cache
Cache post content, translations and nav menu output in persistent object cache.
This MU plugin works well in **production** providing you understand its source code (133 sloc).
### WordPress performance
Please see https://github.com/szepeviktor/wordpress-website-lifecycle/blob/master/WordPress-performance.md
### Usage
Of course you need **persistent** object cache. Consider Redis server and `wp-redis` plugin.
Replace `the_content()` calls in your theme.
**NOTICE** Replace only argument-less calls! `$more_link_text` and `$strip_teaser` are not supported.
```bash
find -type f -name "*.php" | xargs -r -L 1 sed -i -e 's|\bthe_content();|the_content_cached();|g'
```### No-cache situations
- `wp_suspend_cache_addition( true );`
- `define( 'DONOTCACHEPAGE', true );`### Prevent missing plugin
Protection against plugin deactivation.
Copy these to your theme's functions.php.
```php
if ( ! function_exists( 'the_content_cached' ) ) {
function the_content_cached( $more_link_text = null, $strip_teaser = false ) {
the_content( $more_link_text, $strip_teaser );
}
}
if ( ! function_exists( 'get_the_content_cached' ) ) {
function get_the_content_cached( $more_link_text = null, $strip_teaser = false ) {
return get_the_content( $more_link_text, $strip_teaser );
}
}
if ( ! function_exists( 'get_template_part_cached' ) ) {
function get_template_part_cached( $slug, $name = null, $version_hash = '' ) {
get_template_part( $slug, $name );
}
}
```## Little sisters
1. Tiny **navigation menu** cache - for nav menu output
1. Tiny **translation** cache - for translations (.mo files)## Alternative
https://github.com/Rarst/fragment-cache