General Question

soundedfury's avatar

What does adding a question mark to a URL do?

Asked by soundedfury (2536points) February 20th, 2008

For several years now, I’ve used adding a ? to the end of a URL, such as http://www.fluther.com/? as cache-busting trick, but I’m curious what is really happening under the hood. I know that in our CMS that we use at work it serves up “no cache” HTTP headers, but is this standard?

Observing members: 0 Composing members: 0

10 Answers

soundedfury's avatar

Oh, and I know it’s used for URL parameters. I mean a ? with nothing else.

Zaku's avatar

It’s used as a cache-busting trick, by you. Otherwise, I think it’s just allowed because it is the start of the parameter syntax.

glial's avatar

That you are passing parameters to the server. URL Variables.

So I would think that just a ”?” would tell the server that variables are coming, but if there is nothing behind the ”?” refresh the page.

segdeha's avatar

I’m guessing it’s not enough to prevent caching on all browsers, otherwise frameworks like Rails wouldn’t append ? plus a time stamp, they’d just append the ?.

paulc's avatar

segdeha has the right idea. It “cache-busts” because it is indicating to the browser that the request is different though not passing anything after the ? would result in fluther.com/? being cached so you only “bust” you cache once.

aaronblohowiak's avatar

@paulc: that may not be true, as his cms may process GET requests with parameters differently (perhaps by setting a cache-control header.. see 14.9 Cache-Control of http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more detailed info about http and caching)

setting cache-control headers on the precense of GET params is a VERY naive method, and screams “cheap hack” to me.

sometimes, cheap hacks are good enough.

paulc's avatar

@aaronblohowiak, Headers aside, the URI www.example.com/document.ext is different than www.example.com/document.ext?key=value so you are in essence requesting a completely different resource (the browser knows not how document.ext handles its output and so should not judge it to be identical when passed different parameters). Browsers (correctly) cache unique URIs separately.

Using a parameters to define the presence of a header is silly to be sure. However, its not even needed (see above).

aaronblohowiak's avatar

@paulc. You are talking about browser caches and I was talking about server cache-control response headers. GET params are part of the URI and differentiate the contents. You can “bust” the cache on every page load if the previous page load for that URI has a cache-control header that is set to no-cache or has an expiration date/time.

In this way, you can suggest to the browser the caching strategy to be used.

The error in assumption above is that setting a query param necessarily sets the cache-control header. It seems as though soundfury’s CMS will use the precense of query params to set the cache-control header which will “cache-bust” EVERY SINGLE TIME (for compliant broswers,) not just the “once” that you are suggesting.

-Aaron

paulc's avatar

@aaronblohowiak, I understand what you mean now. I hadn’t put together that the CMS was actually the one sending the cache-control header when it had get parameters. I’m curious which CMS this is…

aaronblohowiak's avatar

@paulc, sorry i wasnt explicit in my earlier post. once again, this is purely speculation and would be my first avenue of debugging. (You can check this using the web developer toolbar in ffox)

@soundfoundry: another cache-busting trick you can use is holding the control (or command if you are on a mac) key while pressing the refresh button.. that will tell firefox to go ahead and not use its caches.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther