Does the WordPress initialization scripts run every time a request hits the server?

The index.php file in my WordPress installation directory seems to run several other scripts in order to properly configure the WordPress Environment, and in turn, these scripts define several constants. My question is: does that procedure of running the initialization scripts and defining constants happens every time a requests hits the server, or does it happens only after the first request to the server and these environment constants and settings remain defined until the server is shutdown?

Related posts

Leave a Reply

1 comment

  1. In WordPress (and PHP in general), each request runs in its own environment, that is isolated from other requests and does not share any constants, variables or loaded classes with other requests. Each request starts with a “clean slate” and has to do all initialization work from new. When the request finishes, all data loaded/created by the request is destroyed.

    There are some exceptions to the “total isolation of requests” rule:

    • PHP’s Opcode cache stores the result of parsing a PHP file in shared memory. When the same file is loaded in a later request, the parsing step can be skipped.
    • Sessions preserve some state between requests.