weixin_33698043 2011-10-31 18:28 采纳率: 0%
浏览 18

nginx缓存ajax [关闭]

                <div class="grid--cell fl1 lh-lg">
                    <div class="grid--cell fl1 lh-lg">
                        This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,   or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making   this question more broadly applicable, <a href="/help/reopen-questions">visit the help center</a>.

                    </div>
                </div>
            </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2012-07-28 14:33:24Z" class="relativetime">7 years ago</span>.</div>
        </div>
    </aside>

I'm using nginx for proxy cache and I'm having trouble to make it cache some ajax requests. Nginx are making cache correctly for all pages but not for ajax requests.

The uri for ajax requests are like: /process/leaveyourmessage/getMessages?id=XX

My location config is:

location / {
    proxy_pass http://mydomain.com:8080;
    proxy_cache microcache;
    proxy_cache_valid 200 5s;
    proxy_cache_use_stale updating;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

On the http block I've added:

proxy_cache_path /var/cache/nginx levels=1:2
                 keys_zone=microcache:5m max_size=1000m;

Anyone know what could be the problem? My back end is apache + php


I've found the problem. Nginx respect cache-control and expires header and those ajax was sending it.

Writing down "proxy_ignore_headers Cache-Control Expires;" made it work.

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)