John Doe
John Doe

Reputation: 3691

How can I speed up pages that have a lot of php to load?

Some pages are taking a long time to load. I assume its from all the PHP - using a lot of fopen and fget statements. What can I do to make these pages load more quickly?

Upvotes: 0

Views: 110

Answers (4)

Zach Kelling
Zach Kelling

Reputation: 53879

  1. Use Xdebug to profile your code and refactor it.
  2. Use a PHP accelerator to cache bytecode, like XCache.
  3. Break your page up into smaller chunks and use AJAX to pull them in all at once
  4. Use an HTTP Accelerator like varnish.
  5. Cache bits of the page (or the whole page) any other way.

Upvotes: 1

zerkms
zerkms

Reputation: 255115

If you really need to perform a lot of remote calls with fopen - I would suggest you to create some kind of queues and implement some worker, that can work with threads in simultaneous manner.

So in your php code you put the "tasks" to the queue and waiting for the answers. In the same time fast and performant daemon (written in c/c++/python or whatever language that supports threads well) reads the tasks from queue and puts the responses into another queue.

Upvotes: 1

Matt Mitchell
Matt Mitchell

Reputation: 41861

A database may be faster if you're using a lot of file resources as a data layer solution.

Alternatively, consider caching your pages, beginning with client-side HTTP caching and considering server-side caching later.

Beyond that, more details are needed (at which stage we're basically consulting for you).

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799420

Implement aggressive caching.​

Upvotes: 3

Related Questions