Performance: Session-based authentication
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by managing user state on the server and sending session cookies with requests.
class ApplicationController < ActionController::Base before_action :load_user def load_user @current_user ||= User.find_by(id: session[:user_id]) end end
class ApplicationController < ActionController::Base before_action :load_user def load_user @current_user = User.find(session[:user_id]) if session[:user_id] end end
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Loading user on every request | 0 (server-side) | 0 | 0 | [X] Bad |
| Memoized user loading | 0 (server-side) | 0 | 0 | [OK] Good |
| Large, insecure cookies | 0 | 0 | 0 | [X] Bad |
| Optimized secure cookies | 0 | 0 | 0 | [OK] Good |