dongxue9997 2018-12-06 09:15
浏览 166

强制NGINX不为登录用户缓存内容

I faced an issue which I can’t cope with. I’m forced to use PHP fastcgi cache in NGINX to reduce server load. Such approach works perfectly, but since I use sessions, I need to configure NGINX somehow to return not cached content (or its part) to the visitors who are logged in.

I can’t figure it out since I can learn if user is logged in by checking his session.

if (!isset($_SESSION['subscr_loggedin']) || 
$_SESSION['subscr_loggedin'] !== true) {
...
}

I suppose I need use SSI. However, this method allows to exclude the cache from some PHP template while I need to exclude some functions.

For instance, my visitor can track and collect the TV shows. When he pushes a "track" button, the show adds to his collection. And he must see that the show is tracked when he comes back to the same page! But, if it the page is already cached, the visitor sees that something went wrong since the content is not updated.

So, I have just two options I suppose:

  1. Forbid NGINX cache the content for all the visitors who are logged in;
  2. Don’t cache some blocks on my page. But there are so few data about the usage of SSI.

Both options are acceptable for me. Can anyone assist me with such an issue?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥35 平滑拟合曲线该如何生成
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 自己瞎改改,结果现在又运行不了了
    • ¥15 链式存储应该如何解决
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站