I found and fixed a problem where my utm code was drastically slowing down page loads. The problem was the leading character was a ?. The solution was to change it to a #. Now, we have literally hundreds of campaigns with the leading ? and manually changing them will take forever.

Is it possible to change that ? to a # as the request comes in and avoid the page load issue?

It seems like there should be some way to use Rewrite URL to do it.

If not, can anyone help with why on earth the dang question marks cause a 20 second page load while hashtag is less than 2?

For example, the following has a 15-20 second load time:


Whereas, the following has a 2-4 second load time:

  • I don't know why, and I'm curious to hear answers. – lucgenti Jun 10 '15 at 23:03
  • For clarification, you want to url redirect for lots of urls? – Abu Nooh Jun 10 '15 at 23:52
  • Well each link that is inserted in an email goes to a different URL. There are hundreds of them, and all have a leading "?". So what I have to do is one of two things, implement a rewrite to change the ? to a # or find whatever the heck is causing the problem with the "?". – Shane Weaver Jun 11 '15 at 0:07
  • 15-20 second load time: freejazzlessons.com/… 2-4 second load time: freejazzlessons.com/… – Shane Weaver Jun 11 '15 at 0:14
  • Can you post a complete example URL. ? and # have special/different meaning in a URL, you can't simply use one or the other. If the ? is designating the start of the query string then replacing this with a # will indeed "speed things up" because you're not going to be sending a new request to the server - but also I am surprised if this actually works as intended. It sounds like the query string is breaking your page cache? – MrWhite Jun 11 '15 at 7:44

This looks like a server-side caching issue with your site. (You perhaps need to remove the query string when generating a cache key?)

The problem is with any query string, not just UTM codes. Try appending ?hello=world to any URL and you get an extended (20+ second) load time on the initial (non-cached) request. However, request the same URL again and subsequent responses are 2+ seconds - this is with the local browser cache disabled.

By changing ? to #, you are changing the query string into a fragment identifier. The fragment identifier is not sent to the server, so does not interfere with your server-side cache.

It is perhaps possible to externally redirect from the query string'd URL to one with a fragment id, something like this in .htaccess:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(utm_source=.*)
RewriteRule (.*) /$1#%1 [QSD,NE,R=302,L]

This requires Apache 2.4 for the QSD flag (which strips the query string). The NE flag is required since we are rewriting to a URL with a special character (#) - to avoid it being percent encoded.

However, this is only masking an underlying problem and I would expect could cause more problems in the future.


I think using # instead of ? is worse.

With a standard URL, anything after # normally means a tag on the page and the tag is defined from an ID value or if you want to go old-fashioned, <a name='tagnamehere'>.

If your pages are mainly static (where the content from a URL is the same regardless of who or what accesses the URL), then you need to cache the pages on the server so that the first time the page loads, it can load slow because then the cache file is created while the page is prepared, but the second and subsequent times the page loads, it will load fast because only the cache file is read instead of all the database processing and whatever else is working the server CPU to deliver the page.

If your pages are dynamic, then try to cache all the static parts of the page. For example, if you have a page that displays everything the same except for the date and time value, then cache everything else and have the date and time value load as normal.

When you are done, use webpagetest.org to test your page to see the Time To First Byte value (TTFB). Anything above 0.2 seconds is bad.

See this URL for more of an explanation of when a # can be used in a URL:


  • Everything is cached, using WP-SuperCache for that. Also have Rackspace CDN helping. If I put in the url with the "?" TtFB is close to 20 seconds. If I use the "#" the TtFB is less than 2 as I said above. So using the hashtag gives near instant load time and it is properly tracking the data. The question mark tracks the data but effs up the page load. Also, if you use the "?" it isnt slow only on the first page load. It's slow every single time. – Shane Weaver Jun 11 '15 at 2:00
  • Ideally I would like the ? to work but I have not been able to pin down the reason it isnt. – Shane Weaver Jun 11 '15 at 2:11
  • Could it be that your CDN is slow? or what happens if you use different parameters? Maybe the CDN is being messed up from the parameters you are using? I'm not sure because I haven't used a CDN before. – Mike -- No longer here Jun 11 '15 at 2:15
  • It doesnt matter what parameters are there. The only thing that makes the difference is the "?". – Shane Weaver Jun 11 '15 at 2:22
  • Ok I was just making sure because sometimes, the middleman (aka the CDN) can act differently based on what parameters are passed in and if it works better with different parameters then the CDN server has bugs. Sometimes experimentation is the best answer. – Mike -- No longer here Jun 11 '15 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.