Wincache vs. other wordpress plugin cache RRS feed

  • Question

  • User1726606273 posted


    can Wincache and some other wordpress cache plugins (eg. wp-rocket, wp-optimize,........) be used at same time?

    Whats the difference between wincache and cache mentioned above.


    Tuesday, June 2, 2020 5:58 AM

All replies

  • User409000176 posted

    Well, I guess https://www.iis.net/downloads/microsoft/wincache-extension is a little vague as to what WinCache really does.  Plus, it's a little out of date since WinCache is no longer an opcode cache.  So, let me take a swing at this:

    WinCache has several caching elements.  The largest impact is the file cache.  Any file accessed during a PHP script, as a stream, is cached in memory, such that it avoids going back to the file system on subsequent access.  The file system on Windows is, how shall I put this gently, a bit heavier than on Linux.  Especially when it comes to remote file systems, like SMB/CIFS.  So, any time you can avoid going to the file system during an operation is a good thing.  And one thing that most web page have is a lot of static resources which never change.

    WinCache puts all of these file resources in memory that can be shared between all the php-cgi instances.  And, if you have a heavily loaded site, you may have 10 or 20 or 100 php-cgi.exe's serving content.  What this means is that once a file is loaded by one php-cgi.exe, all the others php-cgi.exe's will be able to find that same resource in memory, and they can avoid hitting the file system.  Nifty, yes?

    WinCache also has a property cache (basically, a name-value cache, exposed using its own extension API's) and a session cache (standard PHP session), which also uses shared memory to hold values.  This ensures that every php-cgi.exe sees a consistent view of the properties.  There are some WordPress plugins which take advantage of this WinCache API surface.

    WinCache 1.x has a PHP opcocde cache as well.  The opcode cache portion has been removed in WinCache 2.x, now that PHP has Zend Opcache in the mainline product.  What is an opcode cache?  PHP is an interpreted language.  When you hit a PHP page, the *.php file is compiled into a set of instructions (opcode array), and then executed by the PHP engine.  If you don't have an opcode cache, you would perform this compile step every time the script was loaded and run.  And compiling, while fast, is a bunch of cycles and file I/O...which we would like to avoid doing on every single page load.  Both WinCache's opcache and Zend Opcache use the same shared memory architecture to ensure that scripts are compiled only once.  So, if you aren't using Zend Opcache, you should.  Go ahead...I'll wait.

    So, the next question is, "Well, what is wp-rocket and wp-optimize doing?"  These are WordPress plug-ins that are doing very different things from what WinCache (and Zend Opcache) are doing.  They have intimate knowledge of HTML, image formats, browser requests, the database that is backing the WordPress site, and so on.  The number one thing that any WordPress cache is doing is caching the results of a complete page rendering, for a relatively short period of time, such that the same page content will be returned, and you don't pay the cost of all of the work that was done to render the page: Reading files, executing PHP code, making off-box calls to the remote database, making off-box calls to the Redis cache, etc., etc..  Any time you can avoid doing something, that's cycles (and bandwidth) you can free up to something else...like serving more requests from your IIS server!  Win!

    Quickly skimming through the FAQ for wp-rocket, and wp-optimize, and W3TotalCache, they do other things to improve performance, such as reducing the total number of bytes a rendered response contains.  Compressing images (because they know that browsers don't really care about having full-pixel images in your tiny 1" x 1" on-screen image), minifying HTML to make the rendered page as small as possible, and re-ordering the HTML to take into account the order in which different browsers behave when they render pages...these are the kinds of things that a WordPress-aware cache is doing.  Any time you can reduce the number of bytes egressing your IIS box per request, means more bandwidth for doing something else....like serving more requests from your IIS server!  Win!

    tl;dr - WinCache does different stuff than WordPress caches.  Yes, you can use them together.

    Tuesday, July 14, 2020 8:06 PM