Giter VIP home page Giter VIP logo

cache-app's Introduction

Without any strategy of cache

=> see commit: http://bit.ly/1wqwvbe)

capture d ecran 2014-10-19 a 21 37 04



With the strategy of cache Cache-Control (private cache for client browser) with a max-age of 2 minutes (120 seconds)

  • At the first refresh: capture d ecran 2014-10-19 a 21 56 02 Notice the "private" mention.

  • Calling the page again (don't do a force refresh, otherwise, your browser will bypass its cache): capture d ecran 2014-10-19 a 21 56 35 Notice that the server is not hit at all.

=> see commit: http://bit.ly/1prET40



With the strategy of cache Cache-Control (public cache for Reverse Proxy / Gateway cache) with a s-maxage of 1 minute (60 seconds)

  • At the first refresh: capture d ecran 2014-10-19 a 22 10 31

  • Calling the page again (60 seconds after the first call): capture d ecran 2014-10-19 a 22 13 13

=> see commit: http://bit.ly/1vQHz2C



With an esi

  • At the first refresh: capture d ecran 2014-10-19 a 22 29 37 We can see that both the page / and the fragment have a stale cache.

  • At the second refresh (less than 20 seconds after the first one): capture d ecran 2014-10-19 a 22 30 02 We can see that both the page / and the fragment have a fresh cache (no need to regenerate the response).

  • A the third refresh (35 seconds after the first refresh): capture d ecran 2014-10-19 a 22 35 17 We can see that only the cached fragment is stale, time to regenerate a new response.

Nota Bene: You can take a look at the Symfony Profiler to notice the second request for the ESI (_fragmentxxxx capture d ecran 2014-10-19 a 22 32 39).

=> see commit: http://bit.ly/1wial91

Now you can have fun with all of that !



You may have notice that you can access the fragment directly from its url. Not that good uh?

Let's secure it with this, in the file security.yml : access_control: - { path: ^/_fragment, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 } - { path: ^/_fragment, roles: ROLE_ESI }

Basically, if the client ip is 127.0.0.1 (the ip of your reverse proxy cache), the fragment is accessible, that way your RPC can get the missing fragment to replace the <esi:include src="xxx"> properly, otherwise, it is accessible by the user having the role ROLE_ESI (which nobody has so it's not accessible).

cache-app's People

Contributors

saro0h avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.