I’m currently developing a Web application with Zend Framework and PHP 5.3. I have a XML file that contain configs and mapping information (+- 1500 lines). On each request I perform an xpath query to get information from that XML file. The information that is found in the XML file is static and do not change after the deployment of the application.
It is a good practice to generated a php file that contain the XML information in a static arrays on the first request and then load that php file on every request to get the information instead of doing queries on the XML?
You can cache the parsed config file as source file with var_export.
Generating code to cache resources is implemented in several places in Zend Framework, for example autoloader, so I presume it is good practice.
There is also another way to cache it – with serialize (make sure to serialize an array, not for example a SimpleXML object) or Zend_Cache which does more or less the same but is more flexible as to how the result is stored.