{"id":13534696,"url":"https://github.com/pressjitsu/pj-page-cache-red","last_synced_at":"2025-04-02T00:30:31.413Z","repository":{"id":46232223,"uuid":"50431614","full_name":"pressjitsu/pj-page-cache-red","owner":"pressjitsu","description":"Redis-backed full page caching plugin for WordPress","archived":false,"fork":false,"pushed_at":"2021-11-04T19:55:57.000Z","size":141,"stargazers_count":97,"open_issues_count":13,"forks_count":24,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-11-02T22:32:49.914Z","etag":null,"topics":["cache","performance","plugin","redis","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pressjitsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-26T13:51:35.000Z","updated_at":"2024-01-26T22:59:19.000Z","dependencies_parsed_at":"2022-07-26T01:02:51.017Z","dependency_job_id":null,"html_url":"https://github.com/pressjitsu/pj-page-cache-red","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pressjitsu%2Fpj-page-cache-red","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pressjitsu%2Fpj-page-cache-red/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pressjitsu%2Fpj-page-cache-red/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pressjitsu%2Fpj-page-cache-red/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pressjitsu","download_url":"https://codeload.github.com/pressjitsu/pj-page-cache-red/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246734817,"owners_count":20825210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","performance","plugin","redis","wordpress"],"created_at":"2024-08-01T08:00:36.405Z","updated_at":"2025-04-02T00:30:31.155Z","avatar_url":"https://github.com/pressjitsu.png","language":"PHP","funding_links":[],"categories":["Page Caching Plugins","PHP"],"sub_categories":[],"readme":"# Redis Page Cache for WordPress\n\nA Redis-backed full page caching plugin for WordPress, extremely flexible and fast. Requires a running [Redis server](http://redis.io/) and the [PHP Redis PECL](https://github.com/phpredis/phpredis) extension.\n\n## Requirements\n\nMake sure you have a running Redis server and the PECL PHP Redis extension installed and active. Both can be found in packages in most Linux distributions. For example on Debian/Ubuntu:\n\n```\nsudo apt-get install redis-server php5-redis\n```\n\nAfter installing the Redis PECL extension, make sure you restart your PHP server.\n\nMake sure your Redis server has enough memory allocated to store your cached pages. The plugin compresses cached pages using gzip to lower memory usage. We recommend anywhere from 16 mb allocated just for page caching. Increase according to your hit-rate. We also recommend disabling flushing Redis cache to disk, and the `allkeys-lru` eviction policy to ensure the server can make more room for new cached pages by evicting older ones. Here is a sample extract from the redis.conf file:\n\n```\nmaxmemory 16m\nmaxmemory-policy allkeys-lru\n```\n\nDon't forget to restart the Redis server after making changes to the configuration file.\n\n## Installing the WordPress Plugin\n\nInstall and activate this plugin like you normally would into wp-content/uploads/redis-page-cache and create a symbolic link from your wp-content directory, to the advanced-cache.php file in the plugin folder:\n\n```\ncd /path/to/wp-content\nln -s plugins/redis-page-cache/advanced-cache.php advanced-cache.php\n```\n\nEnable page caching in your WordPress wp-config.php file with a constant:\n\n```\ndefine( 'WP_CACHE', true );\n```\n\nTry visiting your site in incognito mode or cURL, you should see an X-Pj-Cache- header:\n\n```\ncurl -v https://example.org -o /dev/null\n\u003c X-Pj-Cache-Status: hit\n```\n\nThat's it!\n\n## Configuring the Plugin\n\nThis plugin does not have a settings UI or anything like that. All configuration is done strictly from a PHP file through the `$redis_page_cache_config` global. Create a redis-page-cache-config.php and place it next to your wp-config.php file in your WordPress install. Use the following code in wp-config.php to include this file during runtime:\n\n```\n// After the ABSPATH definition, but prior to loading wp-settings.php\nrequire_once( ABSPATH . 'redis-page-cache-config.php' );\n```\n\nThe contents of your file can define the plugin configuration settings:\n\n```\n$redis_page_cache_config = array();\n\n// Change the cache time-to-live to 10 minutes\n$redis_page_cache_config['ttl'] = 600;\n\n// Ignore/strip these cookies from any request to increase cachability.\n$redis_page_cache_config['ignore_cookies'] = array( 'wordpress_test_cookie', 'openstat_ref' );\n\n// Ignore/strip these query variables to increase cachability.\n$redis_page_cache_config['ignore_request_keys'] = array( 'utm_source', 'utm_medium', ... );\n\n// Vary the cache buckets depending on the results of a function call.\n// For example, if you have any mobile plugins, you may wish to serve\n// all mobile requests from a different cache bucket:\n\n$redis_page_cache_config['unique'] = array( 'is_mobile' =\u003e my_is_mobile() );\n\n// There are some other configuration options you may wish to adjust. You can\n// find them all by looking at the contents of the advanced-cache.php file.\n```\n\n## Purging Cache\n\nBy default, this plugin will expire posts (pages, cpt) whenever they are published or updated, including the front page and any RSS feeds. You may also choose to expire certain URLs or cache flags at certain other events. For example:\n\n```\n// Expire cache by post ID (argument can be an array of post IDs):\nRedis_Page_Cache::clear_cache_by_post_id( $post-\u003eID );\n\n// Expire cache by URL (argument can be an array of URLs):\nRedis_Page_Cache::clear_cache_by_url( 'https://example.org/secret-page/' );\n\n// Expire cache by flag (argument can be an array):\nRedis_Page_Cache::clear_cache_by_flag( array( 'special-flag' ) );\n```\n\nWait, what the heck are flags?\n\nRedis Page Cache stores a set of flags with each cached item. These flags allow the plugin to better target cached entries when flushing. For example, a single post can have multiple URLs (cache buckets, request variables, etc.) and thus, multiple cache keys:\n\n```\nhttps://example.org/?p=123\nhttps://example.org/post-slug/\nhttps://example.org/post-slug/page/2/\nhttps://example.org/post-slug/?show_comments=1\n```\n\nThese URLs will have unique cache keys and contents, but Redis Page Cache will flag them with a post ID, so you can easily purge all three items if you know the flag:\n\n```\n$post_id = 123;\n$flag = sprintf( 'post:%d:%d', get_current_blog_id(), $post_id );\n\nRedis_Page_Cache::clear_cache_by_flag( $flag );\n```\n\nYou can add your own custom flags to requests too:\n\n```\n// Flag all single posts with a tag called my-special-tag:\nif ( is_single() \u0026\u0026 has_tag( 'my-special-tag' ) ) {\n    Redis_Page_Cache::flag( 'my-special-tag' );\n}\n\n// And whenever you need to:\nRedis_Page_Cache::clear_cache_by_flag( 'my-special-tag' );\n```\n\nNote that all the clear cache methods expire (but don't delete) cache by default. If you're running in an environment where background cache regeneration is available, an expired flag will cause that background regeneration while serving a stale copy to the visitor. If this is not the desired behavior, you can use the optional $expire argument in the clear cache methods (set to false) to force delete a flag/URL.\n\n## Support\n\nIf you need help installing and configuring this plugin, feel free to reach out to us via e-mail: support@pressjitsu.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpressjitsu%2Fpj-page-cache-red","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpressjitsu%2Fpj-page-cache-red","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpressjitsu%2Fpj-page-cache-red/lists"}