Posts Tagged ‘php’

Amazon CloudFront: Configuring a CDN in under 5 minutes

Tuesday, November 18th, 2008

I was very thrilled to hear about the public release of Amazon’s much awaited CDN service dubbed CloudFront. It took me 5 minutes to configure and start using it to serve static content off it (I used S3 for static content until now, so the transition was easy).

  1. Prepare an .aws-secrets file to store your AWS access identifiers and get the cfcurl.pl script (tutorial).
  2. Define a Distribution. Save this snippet in a file called create_request.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2008-06-30/">
    ..<Origin>YourBucketNameHere.s3.amazonaws.com</Origin>
    ..<CallerReference>20080930090000</CallerReference>
    ..<CNAME>cdn.example.com</CNAME>
    ..<Enabled>true</Enabled>
    </DistributionConfig>
  3. Run the following command:
    ./cfcurl.pl --keyname <key name from .aws-secrets file> -- -X POST -i -H "Content-Type:text/xml; charset=UTF-8" --upload-file create_request.xml https://cloudfront.amazonaws.com/2008-06-30/distribution
  4. Save the response (especially the E-Tag) for later, you may need it to update the configuration.
  5. Create a CNAME entry in your DNS server using the DomainName in the response.
  6. Done!

I’m trying to think about an elegant way to manage versioning from now on (in PHP). I used to add a query-string version parameter to each resource to deal with client-side caching. With CloudFront, I need actual filenames to change, since Amazon’s servers ignore the query-string parameters when fetching the file from the S3 origin. Any ideas would be greatly appreciated!

Update: see comment below.

qYOUARE

Tuesday, June 10th, 2008

qYOUARE is a small thingy that lets you easily create QR Codes.

When scanned, each qYOUARE links to a specific page, where you can share some information and even have a discussion with whoever scanned the code.

qYOUAREs can be printed on stickers, t-shirts, mugs and can even be sprayed on walls. You can place them anywhere thinkable in the physical world – providing a cool and geeky bridge back to the online world.

http://qyouare.com/about/Creating the website was a learning experience for me, as I have never coded anything larger than a page or two for the Web. Since I always find it easier to develop after going over some sample code, I figured the best way to share my experience would be to make the entire source code behind the web site available for download.

In order to create a new qYOUARE, browse to http://qyouare.com/[your desired code] (I know, the GUI still sucks…)