Showing posts from October, 2018

How To Optimize Your Site With GZIP Compression

Compression is a simple, effective way to save bandwidth and speed up your site. I hesitated when recommending gzip compression when speeding up your javascriptbecause of problemsinolder browsers. But it’s the 21st century. Most of my traffic comes from modern browsers, and quite frankly, most of my users are fairly tech-savvy. I don’t want to slow everyone else down because somebody is chugging along on IE 4.0 on Windows 95. Google and Yahoo use gzip compression. A modern browser is needed to enjoy modern web content and modern web speed — so gzip encoding it is. Here’s how to set it up.
Wait, Wait, Wait: Why Are We Doing This? Before we start I should explain what content encoding is. When you request a file like, your browser talks to a web server. The conversation goes a little like this: Browser: Hey, GET me /index.htmlServer: Ok, let me see if index.html is lying around…Server: Found it! Here’s your response code (200 OK) and I’m sending the file.B…

ORM Patterns: Active Record and Data Mappers for Object-Relational Mapping

What is an Object-Relation Mapper (ORM)? For the “what are you talking about?”s, a little explanation. In an object-oriented system there’s a high probability that you’ll eventually need to safely store your objects so they’ll survive a power outage, memory exhaustion, process shutdown, etc.To do that, you’ll probably end up storing these objects in a relational database (MySQL, Postgres, SQLite, etc) of some kind.And for that, you’ll need a system by which your objects become valid database records.Ideally, that same system should give you back your objects from that same database next time you need them and they aren’t in memory. That’s what people use object-relational mappers to do. Among ORMs, there are a two very common philosophies or patterns: Active Record and Data Mapper. These two have advantages and disadvantages, we’ll explore them both in this article. But since it ended up being a “benefits” and “drawback” articles, let’s first explore what’s good about ORMs in general.