You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question about a problem with v. 2 cache - missing cache files #502
$githubClient = new \Github\Client(
new \Github\HttpClient\CachedHttpClient(['cache_dir' => storage_path('app/cache')])
);
$paginator = new \Github\ResultPager($githubClient);
// The rest of the code with requests
I see the cache files using this code, so I know they are created.
In the v. 2 I've tried the php-cache/filesystem-adapter:
useLeague\Flysystem\Adapter\Local;
useLeague\Flysystem\Filesystem;
useCache\Adapter\Filesystem\FilesystemCachePool;
// ...$filesystemAdapter = newLocal(storage_path('app')); // storage_path: laravel method pointing to "app" storage folder$filesystem = newFilesystem($filesystemAdapter);
$pool = newFilesystemCachePool($filesystem);
$client = new \Github\Client();
$client->addCache($pool);
$paginator = new \Github\ResultPager($client);
// The rest of the code with requests - exactly the same as for the 1.*
The end result is the same as in the v 1.* - that is, I'm successfully downloading a list of gists from github. During debugging I've checked that the cache plugin is added correctly.
The difference is - in the v. 2, with the code as seen above, no cache files are created.
The path is correct, because a "cache" folder is created in laravel storage app folder - but it's empty.
I've tried also with madewithlove/illuminate-psr-cache-bridge. The code with it is somewhat different (the folder path is configured in laravel config), the end result is correct and without errors (I'm downloading a list of gists), but I don't see the cache files, they are not created.
What am I missing? Or how to debug it, any help with where to check what the problem is?
Thank you for a detailed issue. I've copied your code and tested it myself. It all seams to work properly.
The only thing I'm not familiar with is storage_path. I replaced it with
$filesystemAdapter = newLocal(__DIR__);
This will create a cache folder next to the current file. In that cache folder there your cache files will appear. (Be aware that IDEs could be quite slow in showing new files.)
It seems the issue is this line in the HTTP CachePlugin, since all Github responses return the private Cache-Control directive, nothing is ever cached.
But that directive is only for shared caches, you are allowed to cache the response into a private cache, which is my usecase.
Activity
Nyholm commentedon Jan 12, 2017
Thank you for a detailed issue. I've copied your code and tested it myself. It all seams to work properly.
The only thing I'm not familiar with is
storage_path. I replaced it withThis will create a cache folder next to the current file. In that cache folder there your cache files will appear. (Be aware that IDEs could be quite slow in showing new files.)
ksdev-pl commentedon Jan 12, 2017
Thank you for the answer. I will test it later again and I'll let you know.
ksdev-pl commentedon Jan 13, 2017
I've made more tests:
When I'm not authenticating, this code produces a cache file:
But when I add authentication, no cache file is created:
In both cases the end result is correct and without errors, the gists are downloaded.
Am I doing something wrong? What can be the reason of missing cache files with authentication? Or how can I debug it to narrow down the problem?
Anahkiasen commentedon Jan 28, 2017
It seems the issue is this line in the HTTP CachePlugin, since all Github responses return the
privateCache-Control directive, nothing is ever cached.But that directive is only for shared caches, you are allowed to cache the response into a private cache, which is my usecase.
Related issue on php-http's end php-http/cache-plugin#3
acrobat commentedon Feb 14, 2017
Hmm this indeed explains the problem I have that nothing is cached, hopefully we have some kind of solution soon!