Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php-phantomjs: how to enable disk cache

Although phantomjs has a disk-cache option that works when running via command line, when I use php-phantomjs no disk caching is created.
Is there any specific setting I should set on PHP or Apache so that php-phantomjs uses disk-cache?

like image 527
pedropais Avatar asked Jul 01 '26 08:07

pedropais


1 Answers

Think I found out how to answer my own question:

  1. Make sure that Apache user's home is writable by the user running Apache, or at least that $HOME/.qws is writable by that user.
  2. Set $HOME enviroment variable on PHP script:
    $apacheUserData = posix_getpwuid(posix_getuid()); putenv('HOME='.$apacheUserData['dir']);

With the above steps phantomjs binary running from PHP knows how to find Apache's user dir and is also able to write to $HOME/.qws.

like image 119
pedropais Avatar answered Jul 03 '26 21:07

pedropais



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!