0

Just say I have a file configuration.xml that a php script needs to parse in order to function.

I have a single web client connected to the server(which is actually a 400MHz ARM machine running linux) that will be requesting the php page very often. How do I avoid re-opening the configuration.xml file and parsing it every time the php page is requested?

Is there a way to cache this data some how with php?

Please, do not criticize using this machine as a web server. It's soul purpose is not as a web server, but there is a very good reason I am using it as such...

1
  • Convert your xml settings file (why oh why?) into a .php script and let the opcode cache handle it. Commented Sep 6, 2011 at 2:53

2 Answers 2

2

Yes, you can install for example APC and store the result of parsing in shared memory. Or memcached.

Sign up to request clarification or add additional context in comments.

2 Comments

very helpful, apc looks suitable. Thank you.
@user623879: also keep in mind that APC will also improve performance
1

you can make a script (in php CLI for example) that will run on server and parse the XML and save the data to database, or even to a PHP file (a parsed object). you can update this every X minutes for example using cron or plain php (it will be a background job on server).

the php page requested from the web client will just read the parsed data from database (you can serialize/unserialize it) or just include a generated PHP file, that will contain the parsed data.

this is a method that will not require sharing memory etc, but on every request of the web client you will have to include the generated PHP file or the info from the database

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.