3

Is it possible to pass a query string into a style sheet and if so, can the css process it?

i.e. http://www.domain.com/css/somestyle.css?id=102992992

I noticed when viewing basecamps source that the style sheet has a query string, but I don't see how it can be used.

Thanks

2 Answers 2

10

Yes you can pass a querystring - no a plain CSS file can't use it.

There are two reasons to do it:

  1. The css file is being dynamically generated
  2. For versioning, to make sure the browser always gets the latest version (the id could be the last-modified timestamp, for example)
Sign up to request clarification or add additional context in comments.

1 Comment

Yep, #2 is a fairly common way of doing cache-busting.
2

A query string can be used to ensure that clients don't use old, cached versions of the referenced CSS file rather than retrieving the latest version from the server.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.