symfony - Symfony:避免每个请求的会话
问题描述
我有一个基于 symfony 2.8 的应用程序,每个页面请求都会创建每个新会话。
例如,如果 /api/check 被调用 1000 次,则会不必要地创建 1000 个会话。
firewalls: # 禁用资产和分析器的身份验证,根据您的需要调整它 dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false
api:
pattern: /api/
anonymous: ~
stateless: true
main:
pattern: ^/
form_login:
# the user is redirected here when needed to log in
login_path: security_login_register # URL: /willkommen
# login handler via FOSUserBundle
provider: fos_userbundle
# name of input field of csrf token
csrf_parameter: _csrf_token
# token provider
csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4
# DIRECTION OPTIONS:
# /vendor/symfony/symfony/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php
# OPTION 1: if set true, redirect always to default_target_path after login
# DEFAULT: false
always_use_default_target_path: false # DEFAULT: false
default_target_path: profile_order_list # URL: /profile/orders
# OPTION 2: if option 1 not enabled, the URL of _target_path will be used for redirection
# name of input field for redirection for form_login
target_path_parameter: _target_path
# OPTIONS 3: if option 1, 2 not enabled and user_refer is true, URL from $request->headers->get('Referer')
# will be used for redirection
# disabled using header referrer
use_referer: false # DEFAULT: false
# OPTION 4: if nothing found, URL of default_target_path will be used for redirection
# do not remeber_me with higher security
remember_me: false
logout:
path: fos_user_security_logout
target: homepage # URL: /
anonymous: true
switch_user: true
上面的块在安全配置中不起作用。我试图使 /api 路由无状态但不起作用,知道吗?
解决方案
推荐阅读
- python - 如何重命名 python 包?
- uwp - Uwp 使用 mvvm 绑定坐标值
- kubernetes - Kubernetes:你如何列出在 master 上运行的组件?
- python - Python:所有相同的值用“for~in”进入数组
- javascript - 无法通过 nodejs express 从 HTML/JS 客户端获取 ASP.NET Core 3 中的二进制数据
- c# - 检查是否调用了 WCF 服务
- mysql - sql如何选择具有两行或多行的组的倒数第二行
- networking - Taskmanager 无法连接到 Jobmanager [找不到任何不是环回或链路本地的 IPv4 地址。使用本地主机地址。]
- python - 如何使用 sklearn.decomposition FactorAnalysis 在 python 中获取因子载荷
- javascript - 打字稿:如何在构造函数之外初始化类属性