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.

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

报告相同问题?