Thursday, 15 December 2011

It's here! The first Online CloudFront Invalidator

Two blog posts ago, I talked about my discovery of the Amazon CloudFront invalidation service and how I decided to go about getting a tool made for it using JavaScript. Read my early musings over here.

After much deliberation and man-hours, I have finally completed what I set out to do when I entered the JavaScript ranges, armed with a YQL guide published by Yahoo.

I present to you, the Online CloudFront Invalidator!


Read on for more information...



YQL, what?

Thank you Yahoo!
If you have ever come across SQL, the name will ring a bell. YQL is basically what SQL is with the difference being the actual data tables which you can access.

As the slogan, "Query the Web!" implies, YQL was designed to allow for developers to access and manipulate data from many different available tables.

To allow for this 'querying', YQL has to perform various HTTP requests. These requests include GET/POST/PUT requests which are usually done using server-side web programming with languages such as PHP.

With effective use of Open Data Tables however, one can create their own tables to perform GET/POST requests. This is amazing as it allows one to perform these requests via JavaScript. These requests are usually impossible due to the Same Origin Policy.

You might be wondering how I can receive and send data to the YQL servers in the first place. This is because the communication is done using JSONP, which was created specifically for cross-domain communication.

Here's the open data table I created for my purpose. I won't go into the specifics but you can find out how everything works from the useful documentation.



Why YQL?

"Okay great, but why didn't you simply create a server-side proxy? The code already exists here (for PHP), here (for Python), here (for Ruby) and probably at several places more so why re-invent the wheel?"
The answer is performance, security, and scalability.

By not relying on my $3.74/mo VPS, I make sure that the tool does not slow down due to the number of users using it. Also, query times are significantly increased as it is handled by Yahoo!'s network. This increases scalability and performance.

Security is greatly increased since all code is open to you, the user. All handling of data is transparent and you can easily see how sensitive credentials are dealt with on the client, and the signature, sent only to Yahoo!'s YQL server. If any data was being sent to a proxy server of mine, it would be difficult for users to determine whether I am leaking sensitive information.

However, even after implementing client-side signature generation, YQL querying and HTTPS encoded requests, I was accused of trying to steal user credentials. Ah well...



Convenient Features

My invalidator has a few features for your convenience.
  • When viewing the Get Invalidations tab, the invalidation list will be reloaded every 30 seconds if there are invalidations in progress.
  • Your access key, secret key and distribution ID will be filled in for you when you visit the page again, after having performed an invalidation GET or POST request using your details.
  • Also, file names which have been invalidated before are cached, letting you add them back to your new request easily.
  • Amazon states that you have to provide correct paths which start with /. With the Online CloudFront Invalidator, you can paste in full URLs as well as paths which have invalid characters such as spaces in them.



Now that you know that the Online CloudFront Invalidator is safe and easy to use, what are you waiting for?