Giter VIP home page Giter VIP logo

cakephp-cache's Introduction

Freelance PHP Expert ๐Ÿ‘‹

For 20+ years in the PHP world, open source contributor and ecommerce builder. Framework specialist and tooling/automation guru. Mainly backend, but essentially fullstack.

๐Ÿ’ฌ You got a problem to solve? You want some help on a project or a new feature built? Lets find a way to get it solved. Hit me up.

cakephp-cache's People

Contributors

dereuromark avatar jaykay-design avatar jorisvaesen avatar newtonman avatar oxicode avatar volponi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cakephp-cache's Issues

Reset cache

Maybe there already is a way to do this but it would be nice to have an option to refresh the cache when for example a certain URL parameter is passed.

We are using this plugin for a customer that is requesting the possibility to refresh the cache for certain pages manually. Maybe it's already possible to trigger refreshing of the cache from the controller? Then we could implement the rest ourselves.

Refactor the code to use cache engines

Right now the code relies on the hard coded file based caching solution.

It would be much better if the current file based implementation would be turned into a cache engine or simply the existing file based engine could be used.

I would expect the plugin to check for a 'fullPage' cache config, if it doesn't find it, either throw an exception or use default. Guess using default is OK in this case.

Cache is writed with $_POST request

There is a bug in logic of the shutdown function. Sending a POST request from a view get it cached... Then the next GET request load the recent cached view which is the POST result.

The _isActionCachable should check the conditions of the when in the dispacther too.

This bug happens when you want only cache GET request and the configuration in the initialize didn't specify any actions.

This result of the view to be cached with POST result.

DebugKit

Great plugin, works really well.

Is it possible to have the cache working with DebugKit? I was curious to look at memory, timer and includes when the cache is enable.

Thanks

prefix not working in cake-3

I use the Full Page example.
Without the prefix everything works perfectly.
But I have 2 domains with some differences in de head, so I use prefix to create a html view file for both domains.
Files are being created as expected, but they are ignored and recreated on each request.

In my Controller I have:

$this->loadComponent('Cache.Cache', [
'actions' => ['view', 'index'],
'compress' => true,
'force' => true
]);
Configure::write('Cache.prefix', Configure::read('domain.id'));

How can I tell Cache that it should look for [id]-[template]?

File name too long inside error.log

I found a bug that does not generate a cached version of the requested page because the generated filename is to long.

Another important point is that store a huge number of files in one folder causes inodes problems to the system disk, I will try to make some changes then send a PR to this project.

Logs:
2020-12-02 15:00:36 Warning: Warning (2): file_put_contents(/var/www/vhosts/promoview.com.br/www.promoview.com.br/tmp/cache/views/categoria-digital-smartphones-serao-os-protagonistas-das-vendas-digitais-de-natal-html-utm-source-ActiveCampaign-utm-medium-email-utm-content-Score-Group-apresenta-a-2a-edi-C3-A7-C3-A3o-do-Pulso-3B-Painel-que-tosse-conscientiza-sobre-o-distanciamento-social-3B-utm-campaign-Newsletter-Di-C3-A1ria-02-2F12-2F2020.html): failed to open stream: File name too long in [/var/www/vhosts/promoview.com.br/www.promoview.com.br/vendor/dereuromark/cakephp-cache/src/Controller/Component/CacheComponent.php, line 120] Request URL: /categoria/digital/smartphones-serao-os-protagonistas-das-vendas-digitais-de-natal.html?utm_source=ActiveCampaign&utm_medium=email&utm_content=Score+Group+apresenta+a+2a+edi%C3%A7%C3%A3o+do+Pulso%3B++Painel+que+tosse++conscientiza+sobre+o+distanciamento+social%3B&utm_campaign=Newsletter+Di%C3%A1ria+02%2F12%2F2020 Client IP: 189.100.68.224 Trace: Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 159 file_put_contents - [internal], line ?? Cache\Controller\Component\CacheComponent::_writeFile() - ROOT/vendor/dereuromark/cakephp-cache/src/Controller/Component/CacheComponent.php, line 120 Cache\Controller\Component\CacheComponent::shutdown() - ROOT/vendor/dereuromark/cakephp-cache/src/Controller/Component/CacheComponent.php, line 50 Cake\Event\EventManager::_callListener() - CORE/src/Event/EventManager.php, line 353 Cake\Event\EventManager::dispatch() - CORE/src/Event/EventManager.php, line 330 Cake\Controller\Controller::dispatchEvent() - CORE/src/Event/EventDispatcherTrait.php, line 114 Cake\Controller\Controller::shutdownProcess() - CORE/src/Controller/Controller.php, line 700 Cake\Http\ActionDispatcher::_invoke() - CORE/src/Http/ActionDispatcher.php, line 129 Cake\Http\ActionDispatcher::dispatch() - CORE/src/Http/ActionDispatcher.php, line 94 Cake\Http\BaseApplication::__invoke() - CORE/src/Http/BaseApplication.php, line 235 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cake\Http\Middleware\CsrfProtectionMiddleware::__invoke() - CORE/src/Http/Middleware/CsrfProtectionMiddleware.php, line 108 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cake\Http\Runner::run() - CORE/src/Http/Runner.php, line 51 Cake\Routing\Middleware\RoutingMiddleware::__invoke() - CORE/src/Routing/Middleware/RoutingMiddleware.php, line 168 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 AssetCompress\Middleware\AssetCompressMiddleware::__invoke() - ROOT/vendor/markstory/asset_compress/src/Middleware/AssetCompressMiddleware.php, line 57 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cake\Error\Middleware\ErrorHandlerMiddleware::__invoke() - CORE/src/Error/Middleware/ErrorHandlerMiddleware.php, line 96 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cache\Routing\Middleware\CacheMiddleware::__invoke() - ROOT/vendor/dereuromark/cakephp-cache/src/Routing/Middleware/CacheMiddleware.php, line 67 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cake\Routing\Middleware\AssetMiddleware::__invoke() - CORE/src/Routing/Middleware/AssetMiddleware.php, line 97 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cake\Http\Runner::run() - CORE/src/Http/Runner.php, line 51 Cake\Http\Server::run() - CORE/src/Http/Server.php, line 98 [main] - ROOT/webroot/index.php, line 40

DispatcherFilter does not do useful controller callbacks

DispatcherFilter does not Controller startupProcess() function,
https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php#L471

which fires up useful components, such as ACL, to check if user has right to view the cached content.

User with correct access may log out, and the cached version stays on disk. Unauthorized user comes and views cached version.

So use it only in "public controllers" or add such ACL check functionality. Cakephp 2.x cache helper does controller some callbacks. In my opinion every corporate php framework should do it.

It doesn't work on CakePHP v3.6

2019-07-13 22:54:16 Error: [ArgumentCountError] Too few arguments to function Cache\Routing\Middleware\CacheMiddleware::__invoke(), 2 passed in /home/csm/Projects/Local/PFN_BS4/vendor/dereuromark/cakephp-cache/src/Routing/Middleware/CacheMiddleware.php on line 57 and exactly 3 expected

authorization on cahced pages

After implementing Authorization plugin, cached pages don't pass authorizaion checks.
"The request to / did not apply any authorization checks."
Do you know a solution for this?

Solution found .. change order of middleware; cache before Auth and problem is solved

Always serving cached file, even when timing has expired

Hi there,

I've been trying to use this plugin, and it really does work to generate static html pages and serve them when needed. It also does correctly generates a timestamp within the cached file to mark when the generated page will expire (even the cake cache shell understand this timestamp).

However, I could not make the expiration work, and did not found in plugin code where this check is made to debug & improve it.

Analyzing the code, it seems that it should happen at /src/Routing/Filter/CacheFilter.php, function beforeDispatch(), after the checkNotModified($request) bit. Or maybe inside the _deliverCacheFile() function, not sure.

Any thoughts? Can we implement this? I'm willing to try to do it myself, but I'm somewhat a newbie on GitHub collaboration and do not want to break your idea of how to evolve the plugin.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.