Welcome Guest, Not a member yet? Register   Sign In
Redirect vs load view
#6

(09-16-2018, 10:22 AM)Serializable Wrote: And another question  - am I uderstand it right, that controller object (the object of class  Project) will being created every time I request to this controller?
So will the function  `__construct` be process every time before controller logic will be processed?

Yes, to both your questions.

It might be useful to recall how webservers work. Every time it receives a URL, whether it is from a user typing it or from a redirect call, the server starts a new process from scratch. The "process" has no knowledge of any other requests the server is handling or has handled.

The server uses the URL to determine which script files to load, allocates memory for them, runs them and then sends the output of the script to the browser. The "output" might be a request to go to some other URL (a redirect) or some HTML to display, or some AJAX data for the browser to consume. When the server runs out of code to execute (or is told to "exit" the script) the server forgets all about the request. At that point any memory allocated is released and the webserver "process" that handled the request ends. If you have ever read about the web being "stateless" the above is why - webservers to not remember the "state" of any given request.

A "redirect()" call is using code to accomplish the same thing typing a URL in a browser does. The script that calls redirect() ends (redirect calls exit) and the server cleans up that process.

Yes, the same code gets called again and again and again. But that's one of the main things computers are good at.
Reply


Messages In This Thread
Redirect vs load view - by Serializable - 09-16-2018, 10:22 AM
RE: Redirect vs load view - by InsiteFX - 09-17-2018, 03:45 AM
RE: Redirect vs load view - by Serializable - 09-17-2018, 06:59 AM
RE: Redirect vs load view - by Pertti - 09-17-2018, 08:00 AM
RE: Redirect vs load view - by Wouter60 - 09-17-2018, 08:37 AM
RE: Redirect vs load view - by dave friend - 09-17-2018, 09:16 AM
RE: Redirect vs load view - by Serializable - 09-17-2018, 12:25 PM
RE: Redirect vs load view - by dave friend - 09-17-2018, 04:43 PM
RE: Redirect vs load view - by ignitedcms - 09-21-2018, 11:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB