duanjianlu0506 2017-03-13 16:16
浏览 396
已采纳

可以在Redis中存储渲染的html吗? [关闭]

I'm using Symfony framework with Redis as cache. My controller fetches info from third-party API, creates php objects and places them to a Twig template. Is it good decision to cache rendered HTML in Redis? Maybe better to serialize objects and save them? In last case server will spend time to unserializing and templating but I feel there is something not-so-pretty in first case.

Thank you.

  • 写回答

1条回答 默认 最新

  • dsdzvprlp51692469 2017-03-13 18:02
    关注

    For that use a reverse proxy cache like Varnish that is designed for this kind of purposes. It has powerful methods for cache invalidation that are the main cause of headaches when dealing with caches.

    If you use redis each request still impacts your application causing the whole DI container to be loaded, until your events (or whatever method you use) process the request, checks if it is in redis and if it's still valid and deliver it.

    With a reverse proxy cache if your app only is impacted when fresh content is needed.

    As has been said in comments a system like redis can be some kind of "intermediate" cache in which you can store Api results or internal heavy and not so "changing" calculations to improve the overall performance.

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

报告相同问题?

悬赏问题

  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误