0

When I have a PHP script with variable input data getting high traffic, is it a good idea to pre-generate the script content instead of reading the data from a text file? For example I want to change news headlines every 10 minutes. Is it better to rewrite the script with such an array 'URL1'=>'Title 1', 'URL2'=>'Title 2', .. rather than using file_get_contents on a text file?

1
  • flat file? is never as efficient as a RDBMS Commented Jan 29, 2016 at 1:26

1 Answer 1

1

Any of PHP's file handling functions are expensive and would be slower than a DB.

An array referenced with include() would bypass those functions and would have potential to be pretty fast, but your update frequency makes this seem like a bad idea in a high traffic scenario. The file would be unavailable during it's update...every 10 minutes some visitors would generate nasty errors.

You'll be further ahead to tune your database queries and indices and setup some real-world benchmark testing. AJAX could also be your friend here in managing server load.

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

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.