How long are my URLs?

We are trying to reduce the allowed URL length in one of our applications for security reasons. The first question that you need to answer when doing an optimisation like this is “how many characters do I need to keep my application running?” You can look through your apache log files to find out. Here is a command-line script to help you find out how long your URLs are:

cat access.log* | cut -d" " -f7 | awk '{ print length($0),$0 }' | sort -nu

One thing I noticed is that apache logs URL-encoded strings so the line lengths are too high if you have multibyte or special characters in your URLs. I was able to read the results  and do the maths manually this time but I will probably need to sort that out for the next round.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s