Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing After Method if Cache is Found
  • Dear,

    I am running certain Angularjs  / Rest App.. Where i  need to cache my all results of GET. i am using file cache.

    Now i want to cache all request of GET to be cached. for that i have created certain methods which works well perfectly. The caching and Delivering caching is automated and logic is in Backend Controller Only.. So i no need to type the same cache code everytime in any controller and any methods. it is automated for certain user groups.

    Question.
    If cache is found for a url for certain user. I want to avoid executing the method that i called. because i already have result of it. so i want to call after method immediately if i received cache. how it is possible. whenever i called $this->after($cached_content);  i getting the requested method with sqls are executed.

    My Backend Controller

    My Reports Controller


    Best Detailed Info please.. also i think using router is fine... but i tried , not working in this case.. Kindly help with an example


  • That is not easy, and certainly not simply to solve in an example.

    Our app framework solves this routing ALL requests to a single front controller, which has a router method. So that receives ALL requests.

    It then checks login status, it checks access (so other controllers don't have to), and deals with the cache in the same way you want to. It then returns the output from cache, or calls the controller using an HMVC call.

    Obviously, it is complexer than this. You have no routing anymore, so if you need routing, it needs a custom solution to route HMVC calls, etc.
  • Dear,

    In Simple, I am Asking the way that i can redirect my execution from Before block to After() without going to the requested Method..

    Eg.

    If i requested dev.com/home/hello.php which child of Controller_base.

    i want the before() in controller_base which redirect to after() in controller_base(). and no need to go to Controller_home hello Method, when i checked the execution schema. i found base before -> requested controller before() ->method -> base after()

    i sure there is a native method we can forcefully change path to after method. After method only need a response., if it supplied as $this->after($response).  then what is the issue?  is it normal?

    so that i can cache dynamically for every user.

    Hope you understood
  • You can't, unless you overload and rewrite part of the Request class, since that is what calls the different controller methods. It is not something Fuel supports out of the box.

    Convert it so that if before() returns a Response object, the rest of the controller is skipped.

    You can create a feature request for it if you will, on https://github.com/fuel/core/issues

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion