
You also want the menu options to change to: "Home", "About Us", and "Logout", once the user has logged in. Make sure that you activate caching on Web pages that have nothing to do with the user's session state.įor example, you designed your site in such a way that all your Web pages have the menu options: "Home", "About Us", and "Login", displayed when a user is not logged into your application. Don't cache Web pages unless you understand the possible unwanted side-effects of the cache at the client-side. Here's an important point to consider when designing your application. F3 conforms to the HTTP specifications: only GET and HEAD requests can be cached. Fat-Free will not cache a Web page at a specified URL if the third argument in the $f3->route() method is zero or unspecified.

Web pages with static data are the most likely candidates for caching. When someone tries to access the same URL after the 60-second timer has lapsed, F3 will refresh the cache with a new copy. It skips execution of the route handler and serves the previously-saved page directly from disk. The framework uses the cache for an entirely different purpose - serving framework-cached data to other users asking for the same Web page within the 60-second time frame. A similar instruction is automatically sent to the user's Web browser (client-side), so that instead of sending an identical request to the server within the 60-second period, the browser can just retrieve the page locally. In this example, when F3 detects that the URL /my_page is accessed for the first time, it executes the route handler represented by the second argument and saves all browser output to the framework's built-in cache (server-side). Just specify the number of seconds before a cached Web page expires: $f3 -> route ( 'GET /my_page', 'App->method', 60 )

You can activate the framework's cache engine by providing a third argument to the $f3->route() method.
Optimize disk enhanced page and minify disk caching for nfs code#
Caching static Web pages - so the code in some route handlers can be skipped and templates don't have to be reprocessed - is one way of reducing your Web server's work load so it can focus on other tasks.
