Skip to content

Instantly share code, notes, and snippets.

View g-wilson's full-sized avatar

George Wilson g-wilson

View GitHub Profile
@g-wilson
g-wilson / lambda.js
Last active September 27, 2017 17:09
Lambda@Edge function for Cloudfront which adds web security headers to static sites hosted with S3 + Cloudfront
/**
* This script is to be deployed as a Lambda@Edge function for AWS Cloudfront which
* adds necessary web security headers to static sites hosted with S3 + Cloudfront.
* This behaviour is not currently (2017-09-27) supported as a configuration option in S3 or Cloudfront.
*
* Lambda trigger event name: "CloudFront Viewer Response"
* Installation instructions: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-create-functions.html
*
* Extras not currently included:
*

Keybase proof

I hereby claim:

  • I am g-wilson on github.
  • I am gwhizzl (https://keybase.io/gwhizzl) on keybase.
  • I have a public key ASBT4u2KLFdp0Sp0DT_bEk0ZkCHxPI-Gy30uwYM4Zz0kPgo

To claim this, I am signing this object:

/* GRADIENTS */
.phone {
background: #8ffd78; /* Old browsers */
background: -moz-linear-gradient(top, #8ffd78 0%, #0cd318 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8ffd78), color-stop(100%,#0cd318)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #8ffd78 0%,#0cd318 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #8ffd78 0%,#0cd318 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #8ffd78 0%,#0cd318 100%); /* IE10+ */
background: linear-gradient(to bottom, #8ffd78 0%,#0cd318 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8ffd78', endColorstr='#0cd318',GradientType=0 ); /* IE6-9 */

There are many types of caching that will improve website performance. Here are just five:

MySQL query caching

Every read query that Symphony executes is cached by MySQL. It is important to understand that this is not the result of the query, but the SQL statement itself. MySQL retains a pool of these statements so that they are quicker to execute in the future. This is pretty standard, and you can use it in your own applications too by using SELECT SQL_CACHE for your read queries.

Object caching

Once the database has been queried, the results are used to build objects (pages, data sources, sections, field, entries etc.). These objects are alive only for the lifespan of each page, and are destroyed at the end of each request. Systems such as Wordpress allow these objects to be cached and persisted between each page request (using APC, Memcache, flat files or MySQL), thereby shared between all users. Symphony doesn't do this, but it really should.

Fragment caching

If you have one piece of a p