Laravel 4 has some very nice features in which you can build your api on. After reading about some best practices for REST many people suggest using ETags for validation caching. I’ve come up with a realtivley simple solution to enable ETag validation of your api data.
I simply used a filter to catch the response after it was created, created an md5 hash of the content and compared it with ETag in the request. The code in my app/routes.php looks something like this:
Now when I fetch an invoice an Etag is generated, and compared with the one supplied in the request. If they match, the body is discarded and a 304 is sent back.
This obviously has a few gotchas:
It will not lower any server load. In fact this might slightly increase load since you’ll be generating and comapring ETags on each request. This is simply a bandwidth saving solution for you and the client.
I’m hashing the entire body content. For some this might be undesirable. As a minimum hash the data that you need to know if it changed since the last request.
This doesn’t replace other caching methods like memcached, it’s meant to work along side it.
Web notifications have been around for a while, but with Apple’s latest release of OSX 10.8 and notification center they are most likely to become a bit more popular. I had a look into the developer documentation for safari and found a nice chunk of code for displaying notifications in Safari 6.0.
Here is a great tutorial from Dynamic Hosting Blog on installing ssh2 extension for php. I use this often for wordpress installations since I don’t normally setup my server with ftp. This will allow me to download and install updates/plugins using ssh instead of using the less secure ftp.
I found a good use for WordPress’s taxonomy description. I’m using it to display keywords for the meta tag. When a user visits the archive page of a taxonomy the keyword meta will be displayed in the header.
Put the following code in your header file. Then make sure to put in a comma separated list of keywords in the description field of your custom taxonomy or category.
I was having some trouble a while back uploading media to my WordPress install. I would continually get an error stating that the media couldn’t be moved to the correct folder. I had tried all the forum solutions including even changing permissions to 777. Nothing seemed to work. After stumbling across a few threads on wordpress and finding a Mediatemple community wiki article I came up with a solution. Continue reading →
I noticed the other day that Google Chrome was giving me a 400 bad request when I tried to visit one of my web sites. My server is built on linode using nginx as a front end and apache as the back. No other browsers were giving me this problem. I cleared the cache and this fixed the problem, but I had a sneeking suspicion that it would happen again. Oren Solomianik of Life Scaling came up with a solution that seems to do the trick. See the link below.
Our organisation started using Producteev a while back for task management. It’s a pretty decent platform and has a nice api. Angelo R. from http://xangelo.ca has done some work to create a PHP Library for the api. It works well but I noticed that any time you added a space to value that you where sending to Producteev the code broke. I found the problem and have created a new library with the added fix: