RSS

stinogle

Making the web not suck for a while now.

Archive // web

Well, I took a quick look at my Page Speed results today, and it looks like Google is angry at me for my inability to leverage browser caching. Essentially, I’m reaching out to the server for every image on my site, even if the user has loaded it already. Seems like a ton of extra unnecessary work eh?

Well, htaccess to the rescue! I added the following to my .htaccess file, which sped up my site considerably (and also upped my Page Speed score). I opted to set my headers to a long time for both images, css, and js for now, since I don’t really update the look of my site that often. When I do decide to, I’ll most likely rename my js and css files, and removed the old ones.

# Setting Cache Control Headers
# 480 weeks
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</filesMatch>

# 2 DAYS
<filesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>

# 2 HOURS
<filesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</filesMatch>

Anyone out there have any suggestions on ways to set cache control? This was my first attempt at it, and I’d love some feedback!

Bookmark and Share

Ran into this today with a WP site I was working on. I didn’t want the default version of jquery that’s included now with wordpress, so I found this handy dandy script so that I could load the latest from google. I just added it to the bottom of my functions.php file:

//forcing jquery to load the version we want
function my_scripts_method() {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
    wp_enqueue_script( 'jquery' );
}    

add_action('wp_enqueue_scripts', 'my_scripts_method');
Bookmark and Share

This is a copyrighted image

Add this image to your site at your own risk! Scary times!

SOPA is too blunt. Please veto.

Bookmark and Share

PROTECT IP Act Breaks The Internet from Fight for the Future on Vimeo.

Tell Congress not to censor the internet NOW! – http://www.fightforthefuture.org/pipa

PROTECT-IP is a bill that has been introduced in the Senate and the House and is moving quickly through Congress. It gives the government and corporations the ability to censor the net, in the name of protecting “creativity”. The law would let the government or corporations censor entire sites– they just have to convince a judge that the site is “dedicated to copyright infringement.”

The government has already wrongly shut down sites without any recourse to the site owner. Under this bill, sharing a video with anything copyrighted in it, or what sites like Youtube and Twitter do, would be considered illegal behavior according to this bill.

According to the Congressional Budget Office, this bill would cost us $47 million tax dollars a year — that’s for a fix that won’t work, disrupts the internet, stifles innovation, shuts out diverse voices, and censors the internet. This bill is bad for creativity and does not protect your rights.

Mozilla is taking action, and so can you.

Bookmark and Share

Was setting up some HTML5 audio on a site today, and noticed that the .ogg file was not playing in Firefox. After a bit of pulling out my hair, I realized that GoDaddy did not have this mime type setup on my server. So, I tried this in my .htaccess file:

AddType audio/ogg .ogg

And viola! HTML5 audio in Firefox.

Bookmark and Share

So yesterday we needed to build a page that would redirect based on the device a user came from. We needed to know if a user was coming from a Droid, iPad/iPhone, BlackBerry, or Desktop. I grabbed some user agents here, and went to town. Lemme know if you know a better way to tackle this, as I tried to make it as lean as possible.

<%@ page import="java.util.*"%>

<%
	Enumeration e;
	e = request.getHeaderNames();
	String userAgent = request.getHeader("user-agent");
%>



<%

	if(userAgent.matches(".*BlackBerry.*")) {
		out.print ("BlackBerries taste yummy.");
	} else if(userAgent.matches(".*Android.*")) {
		out.print ("These aren't the droids you're looking for.");
	} else if(userAgent.matches(".*iPhone.*") || userAgent.matches(".*iPad.*")) {
		out.print ("Pods or pads, doesn't matter.");
	} else {
		out.print ("I'm a PC.");
	}

%>


Bookmark and Share