Search code examples
phpshared-librariesphp-extension

Is it possible to Implement a shared resource in PHP?


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.


Solution

  • 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.