Performance: OAuth integration basics
MEDIUM IMPACT
OAuth integration affects page load speed mainly during the initial authentication redirect and token exchange phases.
class SessionsController < ApplicationController def create # Use asynchronous background job for token exchange OAuthTokenJob.perform_later(params.to_unsafe_h) redirect_to loading_path end end
class SessionsController < ApplicationController def create # Blocking synchronous HTTP call to OAuth provider response = Net::HTTP.post_form(URI('https://oauth.provider.com/token'), params) user_info = JSON.parse(response.body) # Heavy processing before redirect process_user_data(user_info) redirect_to root_path end end
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous token exchange in controller | Minimal | 0 | Low but delayed by network | [X] Bad |
| Asynchronous token exchange with background job | Minimal | 0 | Low and immediate | [OK] Good |