Skip to content

Validate cache is writable #108

Open
@wmelton

Description

@wmelton

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions