Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Dutch Web Alliance:
Using Varnish with ESI for a REST API
May 08, 2014 @ 15:23:35

In the latest post to the Dutch Web Alliance blog Bas de Nooijer looks at a handy use of ESI in Varnish as a part of the output for a REST API. ESI (Edge Side Includes) let you handle the caching and reuse of fragments of the output from your application and define different caching rules/techniques for each.

For a project I’m currently working on we are implementing a REST API. Performance for this API is critical, so amongst some other solutions Varnish is used. This was done with minimal effort, as the API already had the correct caching headers. There was a noticeable improvement, however I had the feeling this could be improved much more. I realised I can basically compare our REST API to any website, it uses HTTP in the same way. The main diffence is the content being JSON instead of HTML. Just like most websites, our API composes content in many different ways, for instance ‘standalone’ resources, collections of resources or embedded resources. In a website this would be a clear use case for ESI, so why not use it in our API?

He starts off by asking the question "why use ESI in an API" and compares the ESI method to the more traditional caching rules and handling. He includes two diagrams showing the flow of each handling type along with a brief description of how it would extract and combine the data. With the background out of the way, he gets into the code. He shows how to enable JSON caching in Varnish and the JSON tag information you'll need to include to tell Varnish to do its job.

tagged: varnish rest api tutorial cache esi edge side include

Link: https://dutchweballiance.nl/techblog/using-varnish-with-esi-for-a-rest-api

SitePoint Blog:
Book Release - "PHP Master: Write Cutting-Edge PHP Code"
Oct 21, 2011 @ 14:58:25

As is mentioned in this new post to the SitePoint blogs, a new book has been released (by SitePoint press, naturally) about "writing cutting-edge PHP code" by a few well known authors in the PHP community - Lorna Mitchell, Davey Shafik and Matthew Turland.

Savvy PHP web developers can now keep ahead of the game and ensure that their PHP code is safe, secure, and well-structured for the future with the latest release from SitePoint: "PHP Master: Write Cutting-edge Code" by Lorna Mitchell, Davey Shafik, and Matthew Turland.

The book covers a wide range of topics (somewhat replacing SitePoint's usual "anthology" type of book) including:

  • An introduction to OOP
  • Working with databases
  • Creating and working with APIs
  • Design patterns
  • Security
  • Automated testing

As part of a special offer, you can pick up your print+ebook bundle for the price of just the book, about $40 USD. If you'd like a sample before purchasing, they've posted three sample chapters.

tagged: sitepoint book release phpmaster cutting edge code lornamitchell daveyshafik matthewturland

Link:


Trending Topics: