0

Lets say, there is a config file which lists all the JavaScript files used by the webapp. This config file has not just the names but paths to their respective location. & This content will be used by all the users on a site.

Imagine this for all the style sheets, images, scripts etc

  • This is more or less like a global resource for all the users.
  • Loading this for each and every user would cause more memory usage.

Is there a way this resource could be made shared?

As in,

  • always in memory
  • and only one copy for all the users.

Do I need to write a PHP extension for this?
say like xdebug and load it in php.ini?

PHP is not serving any static content here. It is for providing easier way to include the path to files(static files). This will help while coding.

15
  • You just need php opcode cache
    – zerkms
    Jan 2, 2012 at 11:45
  • 2
    Javascript, stylesheets, images and every other resources are retrieved from the browser directly without affecting PHP in any way, so: Why?
    – KingCrunch
    Jan 2, 2012 at 11:45
  • @zerkms looking into PHP opcode cache Jan 2, 2012 at 11:45
  • @KingCrunch Its for a dependency injection module that I have implemented. Jan 2, 2012 at 11:46
  • @zerkms how will a PHP opcode cache as memcache help? Jan 2, 2012 at 11:49

2 Answers 2

3

Assuming from what you said your using Apache.

http://php.net/manual/en/book.apc.php

APC plugin provides byte-code compilation for a speed boost and also provides a data store. See apc_add/apc_store funcs.

Haven't tried it's data store, but it's speed boost is good.

2
  • looking into it.. need some time. Jan 2, 2012 at 12:17
  • tried the data store working fine until now :). Although, I still need to copy the data into each PHP's run-time local memory to actually use it (pointed to by @mario). Jan 3, 2012 at 20:44
1

I don't see why you'd use PHP to serve static content, but:

I usually use memcached for storing shared resources. It's very effective and fast.

But really, you shouldn't let PHP serve static content.

1
  • PHP is not serving any static content. It is for providing easier way to include the path to files(static files). This will help while coding. Jan 2, 2012 at 12:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.