Django 会话在 10 秒内超时

发布于 2024-09-18 10:10:53 字数 1084 浏览 9 评论 0原文

我终于部署了该应用程序。生产和会话超时非常快。
如果我不连续点击链接,链接就会在 15-20 秒后过期

这不会发生在 Dev 中。但设置又完全不同。

这是我在生产中的设置 - nginx + apache (wsgi) + django 1.1.2
后端是mysql。

nginx 中的 keepalive 是“keepalive_timeout 15;”,但文档说它是针对 nginx 启动的进程的,但与此无关。

以下内容位于 settings.py 中 -

`TEMPLATE_CONTEXT_PROCESSORS = (`  
    `'django.core.context_processors.auth',`   
    `'django.core.context_processors.debug',`   
    `'django.core.context_processors.i18n',`   
    `'django.core.context_processors.media',`   
    `'django.core.context_processors.request',`   
    `'myown.custom_settings_context_processor.myown_custom_settings',`   
    `)`   

`SESSION_ENGINE = (`   
        `'django.contrib.sessions.backends.cache'`   
`)`   

`INSTALLED_APPS = (`   
    `'django.contrib.auth',`   
    `'django.contrib.contenttypes',`   
    `'django.contrib.sessions',`   
    `'django.contrib.sites',`   
    `'django.contrib.admin',`   
`)`

如果有更多信息。是必需的,请告诉我,我会放上。 任何关于为什么会发生这种情况的指示,表示赞赏。

I've finally deployed the app. on production and the session timesout very quickly.
If I'm not continuously clicking on links, it'll expire in 15-20 seconds.

This doesn't happen in Dev. but again the setup is completely different.

Here is the setup I have in production -
nginx + apache (wsgi) + django 1.1.2
Backend is mysql.

The keepalive in nginx is "keepalive_timeout 15;" but the documentation says its for the process nginx launches and isn't related.

Following is present in the settings.py -

`TEMPLATE_CONTEXT_PROCESSORS = (`  
    `'django.core.context_processors.auth',`   
    `'django.core.context_processors.debug',`   
    `'django.core.context_processors.i18n',`   
    `'django.core.context_processors.media',`   
    `'django.core.context_processors.request',`   
    `'myown.custom_settings_context_processor.myown_custom_settings',`   
    `)`   

`SESSION_ENGINE = (`   
        `'django.contrib.sessions.backends.cache'`   
`)`   

`INSTALLED_APPS = (`   
    `'django.contrib.auth',`   
    `'django.contrib.contenttypes',`   
    `'django.contrib.sessions',`   
    `'django.contrib.sites',`   
    `'django.contrib.admin',`   
`)`

If any more info. is required, please let me know and I'll put it.
Any pointers about why this would be happening, appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后eg是否自 2024-09-25 10:10:53

感谢 django 团队的 Anil。
看来我没有正确配置缓存。
通过在我的 settings.py 中注释这些行来进入默认缓存,一切都像魅力一样工作!

SESSION_ENGINE = (
'django.contrib.sessions.backends.cache'
)

谢谢 Anil &布赖恩·HV

Thanks to Anil from the django team.
Seems I haven't configured by caching properly.
Went to the default caching by commenting these lines in my settings.py and everything worked like a charm !!!!

SESSION_ENGINE = (
'django.contrib.sessions.backends.cache'
)

Thanks Anil & BrianHV

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文