Select one or more tags, then press “Search Plugins”

Find Plugin with any / all of the selected criteria
Search Plugin

EffortLess Opcode And Object Cache Wordpress Plugin - Rating, Reviews, Demo & Download

EffortLess Opcode And Object Cache Preview Wordpress Plugin - Rating, Reviews, Demo & Download
No ratings yet
Free
Follow for free plugins, new theme releases and theme news

Plugin Description

WordPress Site Health reports two performance items: “Opcode cache is not enabled” and “You should use a persistent object cache”. This plugin reports the state of both and, where the server allows it, changes it.

OPcache keeps compiled PHP code in memory. It is a setting of the PHP installation, so a plugin cannot install it. The plugin shows whether the extension is loaded, whether opcache.enable is on, the main OPcache settings and, when enabled, memory use, number of cached scripts and hit rate. If the extension is loaded but switched off and PHP runs as CGI or FastCGI/FPM, the plugin can add opcache.enable=0 to the .user.ini file in the WordPress folder, between marker lines, leaving other content of that file as it is. PHP does not allow a .user.ini file to switch OPcache on after the server started with it off, so the plugin shows the lines to put in php.ini or the host’s PHP settings instead.

Persistent object cache. WordPress core caches database results only during one request. With a drop-in file, wp-content/object-cache.php, the results are stored in Redis, Memcached, APCu or in files, and reused by later requests. The plugin writes that file from a template with your settings, and removes it again on request or when the plugin is deactivated. The drop-in implements the WordPress cache functions, including wp_cache_get_multiple(), wp_cache_flush_group() and the other multiple-key functions.

How the cache behaves:

  • Entries are stored under a key made of a random per-installation salt, a version token, the group, the site ID (except for global groups) and the key.
  • Flushing the whole cache or one group changes a version token. Nothing is scanned or deleted on the server; old entries are no longer read and expire.
  • Entries saved without an expiry get a maximum age (default 7 days), so old data does not stay on the server for ever.
  • Non-persistent groups registered by WordPress stay in memory for the request only.
  • If the server cannot be reached, or the PHP extension is missing, the cache keeps working for the current request only. The status page then shows the error.
  • incr and decr read, change and write the value; they are not atomic between simultaneous requests.

Tabs and settings

The page has one tab per cache. A green dot on a tab marks the cache that is active. A cache is “installed” when its PHP extension is loaded (Files needs no extension). Activate is only offered for installed caches. Only one object cache backend can be active at a time, because WordPress loads a single wp-content/object-cache.php; activating another backend replaces the drop-in.

  • OPcache tab – status and settings of OPcache. If the extension is loaded and PHP runs as CGI or FastCGI/FPM, Deactivate OPcache writes opcache.enable=0 to .user.ini in the WordPress folder, between marker lines; Remove the plugin’s line takes the lines out again. If the extension is not loaded the tab explains that only the host can install it.
  • Redis tab – host and port (a host name, an address, tls://host, or the path of a Unix socket, in which case the port is ignored; default 127.0.0.1 and 6379), database 0 to 255 (default 0), and an optional password. The password field is always empty when the page loads; leaving it empty keeps the stored password, and a checkbox removes it. The password is stored in the plugin settings and written into wp-content/object-cache.php, because the drop-in loads before the database is available.
  • Memcached tab – host and port (default 127.0.0.1 and 11211).
  • APCu tab – no settings. APCu memory belongs to one web server pool and is not shared between servers.
  • Files tab – needs no PHP extension. Each entry is one file in wp-content/cache/elooc-<salt>/. The files start with a PHP exit statement, and the folder has an index.php and an .htaccess. The files and folders can be read by the PHP user only. Expired files are removed gradually: about every five minutes one request spends up to a fifth of a second cleaning the next sub-folders, and a flush moves the old files aside to be deleted the same way. Reading a file is slower than reading memory, so this helps mainly when database queries are slow (for example a remote or busy database) and the disk is fast; on a host with a fast local database the gain can be small. It does make WordPress report a persistent object cache.
  • Maximum age of an entry (days) – on every backend tab, 1 to 30, default 7. Shared by all backends.

Buttons on a backend tab: Activate (tests the server with the tab’s settings, then saves them and writes the drop-in; reads Save and update when the backend is already active; settings that fail the test are not saved), Save and test the connection (stores and reads back a value, writes no file, and saves the settings only if the test works), Flush the cache and Deactivate (both only for the active backend; Deactivate deletes the drop-in).

Where the page is

  • Single site: Tools > Opcode and Object Cache.
  • Multisite: Network Admin > Settings > Opcode and Object Cache for super admins, who can change everything. Each site has a read-only copy under Tools. The drop-in and the cache are shared by the whole network; entries of each site are kept apart by the site ID.

Notes and limitations

  • The drop-in is a PHP file in wp-content; PHP must be able to write to that folder to install or update it. If it cannot, the plugin shows an error and writes nothing.
  • The Redis, Memcached and APCu backends need their PHP extensions. The plugin does not install them. The Files backend needs only a writable wp-content folder.
  • OPcache cannot be installed by a plugin. If the status page says the extension is not loaded, the host has to enable it.
  • Memcached and APCu limit the size of a stored value; very large values may be refused by the server and are then read from the database again.
  • APCu memory is per web server pool and is not shared between servers.
  • The settings are network settings on Multisite.
  • Changing the backend or the server settings and clicking install rewrites the drop-in; entries in the old server are not removed and expire by themselves.
  • OPcache can be switched off through .user.ini when the extension is loaded and PHP runs as CGI or FastCGI/FPM. Switching it on needs php.ini or the host.
  • Activating a cache, or changing which server it uses, gives it new keys, so entries from an earlier activation are never read again. Saving only a different maximum age keeps the keys.
  • If the cache server cannot be reached, or an operation on it fails, the request carries on without it and leaves a marker file in wp-content/cache. The next request that reaches the server flushes the cache first, so a change made during the outage cannot leave an old entry behind. After the server fails, the plugin does not try it again for 30 seconds, so a down server does not slow down every page. The same marker is used when WP-CLI changes content while APCu is the backend, because the command line has its own APCu memory.
  • A flush or a flushed group leaves the old entries on a Redis or Memcached server until they expire, up to the maximum age. For Redis, use a dedicated database or set maxmemory-policy to volatile-lru or allkeys-lru, so the old entries are evicted when memory runs short; a write that Redis refuses for lack of memory is skipped without switching the cache off. Memcached and APCu evict the oldest entries on their own.
  • Cached values are signed with a secret kept in wp-content/object-cache.php (readable by the PHP user only). The signature covers the key and the expiry time, so a value written or copied into the cache server by somebody else, or one that has run out, is treated as a miss.
  • Deactivating the cache, or deleting the plugin, removes the cache folder of the file backend; deleting the plugin also removes the plugin’s lines from .user.ini.

External services

The plugin connects only to the Redis or Memcached server that you enter on its settings page, from your own web server. No data is sent to a third party. The “Support the development” notice contains a link to https://id7.dev/donate/ that opens only when you click it.

Screenshots

No screenshots provided


Reviews & Comments