Everybody Staze...

Nobody leavz...

  • Home
  • About Me
    • LinkedIn
    • Lab
  • Contact
  • Links
  • Reviews
  • Sitemap
  • Weather
You are here: Home / Archives for Wordpress

Optimize Prime

2010/04/26 By staze

Using the wonder that is a personal website, I’m spending today working on optimizing page load times on my site. I’m already ran my theme images through smush.it, and am now working on hosting static files on a non-cookied domain.

This is a test image:

Better rewrite code: here dealing with better mod_rewrite code for a wordpress permalink site, is, amazing.

It significantly sped up this site, and I’m planning to implement it on a couple other sites tomorrow at work.

Also of note, I do a fair amount of post revisions, which added up to about 600 or so revisions in wordpress. That can really slow down a site. So, I ran a nice plugin (though the “copy” on the wordpress site is HORRIBLE) called Delete-Revision that really helped speed up things (in addition to the above).

Sweet!

Links of Interest:

  • http://storecrowd.com/blog/wordpress-optimisation/
  • http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html

Update: So, I got my site up to an “A” score (90 points) on YSlow. The main problems were that for some reason, js files weren’t being compressed, I didn’t have ETags configured, and I needed to get Expires Headers working. They are now working. When I started, my score was in the 70’s. As for Google PageSpeed, I’m at a 95/100. For the longest time, I couldn’t get cookies to not cross domains. Turns out, hidden in the google docks here, I had to set the setDomainName to “None” to disable cross subdomain tracking. Since I got that fixed, google is bitching about parallelizing downloads. So, I’ll have to work on that a bit more. Might set up a rewritemap to randomly rewrite requests to static content to various aliases of my static subdomain… we’ll have to see if this works. =/

Filed Under: Sys Admin Tagged With: mod_rewrite, optimize, smush.it, Wordpress

URL Shortener

2010/02/28 By staze

So, it’s been a desire of mine for a while to make up a URL shortener. It seems like such a trivial coding experiment, but a fun one.

The first hurdle, getting something better than base10 for the URLs. That’s fairly easy, in that you can look here. The code he lists isn’t complete, as you need some other stuff. So, go grab the Cassis project code instead.

Note: when you “include_once” that code, you’ll want to do it like:

ob_start();
include_once("./cassis.js");
ob_end_clean();

Next you’ll need to code up something to add URLs to your database. That’s also easy enough. My suggestion would be a simple table that would have “id”, “shortcode”, and “url”. Make id a primary key, and add an index on the “shortcode”. Maybe one on the “url” if your going to be using the system heavily enough to require checking to see if a URL exists already before blindly creating a new short-url.

The last hurdle is to write the decoder. Basically, just have it look for “GET”, and look that up in the DB table, then set the “header(location: )” to be the URL in the for that short code.

Now, normally, you’d have a mod_rewrite rule that looked something like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule shortener.php?url=$1 [L]

Except, WordPress permalinks use something similar, and the two don’t play nice. Now, it would be cool to pass all URLs on to the decoder, and if it didn’t exist in the DB, you’d pass it on to the wordpress index.php. I haven’t quite figured out how to do that, but I found a pretty decent work around.

RewriteRule ^z(.*) shortener.php?url=$1 [L]

Stick that before the WordPress rewrite rules. What that will do is, if there’s a URL that starts with “z”, it’ll pass whatever comes after that “z” on to the decoder. Personally, I don’t have any pages, or files on my website that start with “z”, so it’s safe for me to do. Your experience may vary. If the decoder doesn’t find the url in the table, it simply redirects to my main page. I think I’ll change that to a 404 here once I am further along.

I’m going to keep playing with this. And hopefully, make some pretty spiffy use of it, but for now, it’s “basically” working. I’ll try to remember to post back on this topic when I have more to report on it. =)

Special thanks to my friend Aaron for the advice on this one.

UPDATE 1: I got 404’s to work for non-existant short codes. So, the key with wordpress is to use something like this

header("HTTP/1.1 404 Not Found");
include("index.php");

Basically, I was trying all kinds of other things, then realized that index.php for wordpress will look for the header state, and redirect appropriately. So, that’s it. It now throws a 404 (which, without that include, it would throw a 404, but it was just a blank page)… Cheers!

Filed Under: Coding Tagged With: Base60, URL Shortener, Wordpress

WordPress auto-update

2010/02/15 By staze

Just a quick note. WordPress 2.9.2 came out today, and I found that since my server upgrade, the core auto-update/upgrade feature wasn’t working. It wanted me to have FTP access.

Turns out that the website folder itself (in my case, since I host on a Mac, a folder within /Library/WebServer/Documents) wasn’t owned by www. Once I chowned that to www, the auto-upgrade worked perfectly.

Everything else was already owned by www… so, just make sure, the folder wordpress resides in is also owned by the web user (the user httpd runs as).

Good luck! And remember, Happiness is only a chown away.

Filed Under: Sys Admin Tagged With: automatic update, update, upgrade, Wordpress

« Previous Page
Next Page »

Weather

Categories / Archives

  • Apple
  • Coding
  • Electronics
  • Energy
  • Home Ownership
  • Miscellany
  • Politics
  • Prius
  • Sys Admin
  • Travel
  • Uncategorized
  • Work
  • June 2026
  • April 2026
  • August 2025
  • April 2025
  • January 2024
  • February 2021
  • July 2020
  • January 2020
  • April 2019
  • March 2018
  • February 2018
  • June 2017

Copyright © 2026 · Staze On Genesis Framework · WordPress · Log in