Back when IE 9 came out, it was the first major browser to start caching redirects to improve performance. The IE team wrote a detailed blog post about it, but they still got some backlash (mainly from people that didn't set correct no-cache headers on redirects with side effects, like login pages).

The recently released version of Safari for iOS 6 has started caching AJAX POST requests, with no notification to developers at all. Not only is this unexpected, but it goes against the HTTP 1.1 standard, which states:

9.5 POST

...

Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields.

This means that if you have something like an edit page that uses AJAX to post the form, the first edit will work, but subsequent edits will return a cached "Success" message instead of sending the request to the server!

This is somewhat similar to Internet Explorer caching AJAX GET requests, except caching GET requests is nowhere near as dangerous. While GET requests are allowed to be cached, POST requests are not idempotent (they can have side effects) so they should never be cached. Sure, IE caches AJAX GET requests more heavily than other browsers, but this is allowed in the HTTP specs:

The response to a GET request is cacheable if and only if it meets the requirements for HTTP caching described in section 13.

Caching POST requests is horrible. How many times have you added no-cache headers to your POST pages? I'm going to have a guess and say never, since no other browser in the history of the World Wide Web has cached POST requests. This move has essentially broken the functionality of some AJAX-based edit forms, and developers might not notice the breakage initially. I hope this is a bug and not expected functionality, and it gets fixed at some point. Safari used to be a horrible browser with many DOM issues... I hope it's not heading this way again.

In this post, I'll discuss more of my opinions regarding JavaScript development. Please read the first post in the series if you haven't already. In this post, I'll cover some relatively important language features that don't seem to be covered in a lot of basic JavaScript guides. I'm assuming you have a basic knowledge of JavaScript. Let's begin.

Functions are variables

In most programming languages, functions are a pretty basic language feature. They're quite nice for structuring your code, but don't really have any built-in awesomeness. Some programming languages have features to dynamically call functions at run-time (usually referred to as reflection), but JavaScript has a LOT more power in this area. In JavaScript, functions are known as first-class objects. Functions are stored in normal variables, and you can create new ones (known as anonymous functions) and edit existing ones on the fly. Functions can also be return values from other functions! This enables a whole range of different programming techniques known as metaprogramming.

Let's take a look at some examples.

Read more ⇒

I thought I'd give some link love to some of the lesser-known web development blogs I enjoy reading. This post was prompted by a post about my site at GiveUpInternet.com. I didn't expect the link (as I don't think my blog is very good for web development stuff), but I do appreciate it heaps! This blog hasn't really focused too much on web development, perhaps I should post more web development articles ๐Ÿ˜ƒ

  • GiveUpInternet.com โ€” As it says on the site, "Give Up Internet is a Humor Blog for Internet People and Developers." While it's technically not a web development blog, I love the posts on this site. Unlike a lot of other "humour" sites that post stupid things a lot of the time, it's got actual funny posts. It's one of the only humour blogs that I'm subscribed to.
  • The CSS Ninja by Ryan Seddonโ€” This is a great blog about nice little tricks that can be done in CSS. One of its focuses is doing things that previously required JavaScript, in pure CSS (no JavaScript whatsoever). This includes cross-browser CSS-styled checkboxes, a lightbox in pure CSS, and an easy way to preload images using CSS2.
  • David Walsh's blog โ€” David is one of the core MooTools developers, and as such, he blogs mainly about JavaScript, and occasionally some PHP snippets. While, in my opinon, his posts on PHP are often messy ๐Ÿ˜›, his posts on JavaScript are excellent.
  • AdequatelyGood.com by Ben Cherry โ€” If you're interested in JavaScript (especially the nitty gritty of its internals), this is by far the best blog on the topic that I've seen. Ben has written detailed articles on a lot of unique features of JavaScript, including scoping and "hoisting", and how it handles object to primitive conversions.
  • Hallvord R. M. Steen's blog and the Opera sitepatching blog โ€” Hallvord is a developer for Opera Software. His blog covers the state of the web as it unfortunately is at the moment - Broken browser sniffer scripts, standards violations, and just general scripting stupidities. Things are definitely improving, but there's a LOT of broken scripts out there. Opera has a file called "browser.js" that contains patches to make these broken sites work correctly in Opera. Hallford's blog (and the Opera site patching blog) detail the things that Opera does to patch these broken sites. There have been some very interesting posts, including the horrible XML and XSLT on the Israeli rail website, how Google Docs used to print documents, and many others.

That's all for now... I might eventually write another blog post like this. Or a proper blog post ๐Ÿ˜› ๐Ÿ˜ƒ

Until next time,

โ€” Daniel

In this post, I'll discuss some of the techniques that I personally write JavaScript. There's no right or wrong, this is all my opinion (still, feel free to flame me if you feel it's necessary ๐Ÿ˜›). This post is aimed at people that understand basic JavaScript and HTML techniques, and want to see how I code my JavaScript. I will talk about the JavaScript of the past, how it's changed, and some techniques used in modern JavaScript development. This will probably be a multi-part series if I ever get around to writing more posts ๐Ÿ˜›ย 

Read more ⇒