Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate cache is writable #108

Open
wmelton opened this issue Jun 2, 2018 · 0 comments
Open

Validate cache is writable #108

wmelton opened this issue Jun 2, 2018 · 0 comments

Comments

@wmelton
Copy link

wmelton commented Jun 2, 2018

If cache directory exists but is not writeable, the library fails silently and does not cache any responses when using Doctrine Cache + Filesystem Cache.

Example:

Set cache directory permissions to 644, for example on my machine.

$stack = HandlerStack::create();

$stack->push(
  new CacheMiddleware(
    new PrivateCacheStrategy(
      new DoctrineCacheStorage(
        new FilesystemCache($this->_cacheDir)
      )
     )
  ),
  'cache'
);

$this->_client = new Client(['handler' => $stack]);

In this scenario, all responses will contain [X-Kevinrob-Cache] => Array ( [0] => MISS ) regardless of the Cache-Control response.

If you update Permissions for the cache-directory to 755 (more common) immediately caching starts to work creating sub-folders and cache files in the directory. X-Kevinrob-Cache = HIT.

Would be useful to do a writeability/permissions on the cache directory check with the Filesystem Cache and throw an error as a sanity check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants