douyousu9691 2016-03-04 17:46
浏览 314
已采纳

使用cloudflare缓存动态页面

We have a number of pages where the only dynamic content is the user info (Name, profile link, # of items in shopping bag) which is at the top corner. These pages can take upto a second or more to load sometimes.

We are thinking of changing the pages so that the entire HTML page is cached using Cloudflare, then when it's displayed, JavaScript will check for the presence of a cookie name "Username" and "CartCount" and update the profile accordingly, or if the cookie is not available, show the customary login icon.

Is this method feasible and are there any security precautions that need to be taken?

  • 写回答

1条回答 默认 最新

  • duanfu1942 2016-03-05 05:08
    关注

    Not only it's feasible, it's actively used by some of the big websites - eg. Airbnb, TripAdvisor.

    You may notice that if you open these websites (and many others) at first it looks like you are not logged in, and then later DOM updates with your user name.

    The only issue I see is CSRF tokens - if you cache the pages, your tokens will be outdated and not longer useful. You will have to turn off CSRF checks for your AJAX requests and sign in page.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染