473,549 Members | 2,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query parameters at the end of the JavaScript file

I am starting to find more web pages that are using a query parameters
after the JavaScript file.

Example can be found at www.opensourcefood.com. Within the source
you'll see: <script src="/shared/scripts/common.js?revis ion=1.6"
type="text/javascript">.

I am trying to see if there is any big deal to this or a best practice
that is starting to creep up in the JavaScript community. If this is
used only as a way to distinguish what file of JavaScript being used
why not append something inside the file? Has anyone else seen this
or know of more reasons to do this?

Aug 10 '07 #1
17 2714
On Aug 10, 12:26 am, NeoAlchemy <NeoAlch...@gma il.comwrote:
I am starting to find more web pages that are using a query parameters
after the JavaScript file.

Example can be found atwww.opensourc efood.com. Within the source
you'll see: <script src="/shared/scripts/common.js?revis ion=1.6"
type="text/javascript">.
I don't like that at all. It indicates that they are using CGI to
serve static script files. I assume they are static as the only
information in the query is a version number. Some browsers will not
cache files retrieved with a querystring, so this would seem like a
crazy thing to do.
I am trying to see if there is any big deal to this or a best practice
that is starting to creep up in the JavaScript community. If this is
used only as a way to distinguish what file of JavaScript being used
why not append something inside the file? Has anyone else seen this
or know of more reasons to do this?
There is a good reason to put version info in the filename of a static
script (eg common_v1_0.js) so that you can make use of the Expires and/
or Cache-Control headers. For instance, you could configure your
server to serve all static scripts with an expiration of thirty days
(one year max) and browsers will cache and re-use them without having
to ask the server when they were last modified each time a page is
loaded. When you update a script, you bump the version number to
prevent browsers from using a cached, outdated copy.

Aug 10 '07 #2
David Mark wrote:
On Aug 10, 12:26 am, NeoAlchemy <NeoAlch...@gma il.comwrote:
>I am starting to find more web pages that are using a query parameters
after the JavaScript file.
Example script src="/shared/scripts/common.js?revis ion=1.6"
I don't like that at all. It indicates that they are using CGI to
serve static script files.
It's not definitely indicating that it's using CGI. You can send that
request to any standard web server and it will totally ignore everything
after the ? and will always return the same static file. It could be
just that they're using it for tracking which version of a some other
file is making requests to common.js. With a bit of server log
processing you can determine for example that you have 50% of requests
to common.js are being made by version 1.6, 30% are being made by 1.5
etc etc. That's one possibility. Or that 1.6 could be to indicate which
version of JavaScript is supported in the browser (script
language="JavaS cript1.6") and the site is using it for some kind of
monitoring of browser stats. One thing I've done also with JS requests
is to tack onto the end of it a random number to cache-bust the request
(src='file.js?" +Math.random() .....) which is useful if you know the
file could change at any time and you don't want to rely on the browsers
own cache settings.
Aug 10 '07 #3
On Aug 10, 1:53 am, Stevo <ple...@spam-me.comwrote:
David Mark wrote:
On Aug 10, 12:26 am, NeoAlchemy <NeoAlch...@gma il.comwrote:
I am starting to find more web pages that are using a query parameters
after the JavaScript file.
Example script src="/shared/scripts/common.js?revis ion=1.6"
I don't like that at all. It indicates that they are using CGI to
serve static script files.

It's not definitely indicating that it's using CGI. You can send that
request to any standard web server and it will totally ignore everything
It definitely could indicate that they are using CGI. If not, then
they are doing something really silly.
after the ? and will always return the same static file. It could be
just that they're using it for tracking which version of a some other
Like that.
file is making requests to common.js. With a bit of server log
processing you can determine for example that you have 50% of requests
to common.js are being made by version 1.6, 30% are being made by 1.5
etc etc. That's one possibility. Or that 1.6 could be to indicate which
version of JavaScript is supported in the browser (script
language="JavaS cript1.6") and the site is using it for some kind of
The script element would have to be dynamically generated.
monitoring of browser stats. One thing I've done also with JS requests
is to tack onto the end of it a random number to cache-bust the request
(src='file.js?" +Math.random() .....) which is useful if you know the
file could change at any time and you don't want to rely on the browsers
own cache settings.
That makes no sense to me. Every page on the site would have to
download the script every time. If the script is that dynamic, then
it should be served by CGI with appropriate headers to prevent
caching.

Aug 10 '07 #4
David Mark wrote:
It definitely could indicate that they are using CGI. If not, then
they are doing something really silly.
Absolutely, they could be. Which would be dumb.
>Or that 1.6 could be to indicate which
version of JavaScript is supported in the browser (script
language="Java Script1.6") and the site is using it for some kind of
The script element would have to be dynamically generated.
True. I was just trying to think of something it could be used for and
that's all I came up with ;-)
>One thing I've done also with JS requests
is to tack onto the end of it a random number to cache-bust the request
(src='file.js? "+Math.rand om() .....) which is useful if you know the
file could change at any time and you don't want to rely on the browsers
own cache settings.
That makes no sense to me. Every page on the site would have to
download the script every time. If the script is that dynamic, then
it should be served by CGI with appropriate headers to prevent
caching.
It was only one page, not every page on the site and I only had to do it
because even with all the headers set to not cache and with a short time
to live, some browser configs were still not reloading it, instead using
a cached version and so the user wasn't getting what they wanted (the
updated file). Of course these days I'd do an XHR call to get the info
rather than reading a dynamically updated .js file. It was the 90's,
they were wild and crazy times.
Aug 10 '07 #5
David Mark wrote:
On Aug 10, 12:26 am, NeoAlchemy wrote:
>I am starting to find more web pages that are using a
query parameters after the JavaScript file.

Example can be found atwww.opensourc efood.com. Within
the source you'll see:
<script src="/shared/scripts/common.js?revis ion=1.6"
type="text/javascript">.

I don't like that at all. It indicates that they are using
CGI to serve static script files.
It does not. It may indicate that the script elements are being
dynamically generated, but not even that for certain.
I assume they are static as the only
information in the query is a version number.
Some browsers will not cache files retrieved with a
querystring, so this would seem like a crazy thing to do.
<snip>

That would be a faulty caching scheme.

This is done (mostly) precisely because browsers do consider the query
string when caching the results of HTTP GET requests. It is a simple
scheme; suppose you have a site/application that has many javascript
files. You would (mostly) want these cached by the browser (as they will
not change in the short term), but if they were changed (or some were
changed) you would not want the already cached versions used when the
visitor accessed dynamic pages that employed the features that had been
changed. So you update the version number in the script elements (with
an application wide-variable if they are dynamically generated) and the
browser sees the GET requests as distinct from the last version that it
has cached, so it must download and use the new versions. But form them
on, while the version on the query does not change, it can re-use these
new versions from its cache.

Richard.

Aug 10 '07 #6
NeoAlchemy wrote:
Example can be found at www.opensourcefood.com. Within the source
you'll see: <script src="/shared/scripts/common.js?revis ion=1.6"
type="text/javascript">.

I am trying to see if there is any big deal to this or a best practice
that is starting to creep up in the JavaScript community. If this is
used only as a way to distinguish what file of JavaScript being used
why not append something inside the file?
You mean something like a version number?
Has anyone else seen this or know of more reasons to do this?
Possible reasons I can think of:

1. Trying to work around locally cached script resources with different
URIs for the same server resource. Implementing proper cache control
via specified and well-supported HTTP headers would be more reasonable
than that.

2. Using server-side programming to generate (parts of) the served script
resource. The query part could indicate to include a different snippet
of code depending on its value.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 10 '07 #7
Thomas 'PointedEars' Lahn wrote:
NeoAlchemy wrote:
>[Why `/shared/scripts/common.js?revis ion=1.6'?]

Possible reasons I can think of:

1. Trying to work around locally cached script resources with different
URIs for the same server resource. Implementing proper cache control
via specified and well-supported HTTP headers would be more reasonable
than that.

2. Using server-side programming to generate (parts of) the served script
resource. The query part could indicate to include a different snippet
of code depending on its value.
3. Using the query part as retrieved with window.location .search
to modify client-side script behavior according to the version
number passed, trying to stay compatible to previous versions
that can be retrieved with a different query part.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 10 '07 #8
On Aug 10, 3:36 am, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
David Mark wrote:
On Aug 10, 12:26 am, NeoAlchemy wrote:
I am starting to find more web pages that are using a
query parameters after the JavaScript file.
Example can be found atwww.opensourc efood.com. Within
the source you'll see:
<script src="/shared/scripts/common.js?revis ion=1.6"
type="text/javascript">.
I don't like that at all. It indicates that they are using
CGI to serve static script files.

It does not. It may indicate that the script elements are being
dynamically generated, but not even that for certain.
As was discussed, I would have been more precise to say that it may
indicate this.
>
I assume they are static as the only
information in the query is a version number.
Some browsers will not cache files retrieved with a
querystring, so this would seem like a crazy thing to do.

<snip>

That would be a faulty caching scheme.
Browsers are not supposed to cache GET requests with queries AFAIK. I
am aware that some do. I am not sure what scheme you are talking
about.
>
This is done (mostly) precisely because browsers do consider the query
string when caching the results of HTTP GET requests. It is a simple
scheme; suppose you have a site/application that has many javascript
files. You would (mostly) want these cached by the browser (as they will
not change in the short term), but if they were changed (or
[snip]

I prefer to put the version in the filename and use headers to
indicate that the scripts expire at some far-off date (like a year in
the future.) Then the browsers don't have to negotiate with the
server about last modified dates every time the page loads. When the
scripts are updated, the filenames are changed to reflect the new
version, pages are updated to reference the new file and the cached
copy is orphaned.

Aug 11 '07 #9
Lee
NeoAlchemy said:
>
I am starting to find more web pages that are using a query parameters
after the JavaScript file.

Example can be found at www.opensourcefood.com. Within the source
you'll see: <script src="/shared/scripts/common.js?revis ion=1.6"
type="text/javascript">.
While your example made your meaning clear, you should, for your
own benefit, try to express technical questions more precisely.

There are no query parameters at the end of the file, or after
the file. They are appended to the end of the file NAME.
--

Aug 11 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3346
by: ubccis | last post by:
Hi. I'm wondering if you can dynamically query a database with javascript and php. For example, can I select something on the select menu and dynamically query the database and populate another select box without reloading the page?
4
4652
by: Pasquale | last post by:
Hello, I wondering if there is a way to dynamically update a select list with javascript from a database query without having to reload the page to update the list?
1
7123
by: Glenn | last post by:
Searching through google groups, I have not found anyone able to modify the query string of a request. I was hoping to make the query string as short as possible so that a search with many criteria could be bookmarked. I had planned to have the query string be key=value for each criteria But with dropdowns, the default choice is always...
1
2902
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access 2000. The access file is in access 2000 format. I have a form that will hold the relevent parameters for the query/report that reports the statistics...
2
2787
by: John | last post by:
Hi all, I had an .aspx page which would be opened modally from a previous page and just prior to the parent opening the aspx page, a javascript would run and pass parameters like mypage.aspx?parm1=a&parm2=b. I would then access the parameters in my code-behind as simple request variables and everything worked fine. I now have to open an...
0
1999
by: R L Vandaveer | last post by:
I am having an interesting and rather frustrating issue with the encoding/decoding of parameters with the ASP.NET runtime. What I am doing isn't exactly revolutionary so hopefully someone has an answer for this. I have a page that accepts a number of parameters. Those parameters may sometimes include URL reserved characters like spaces and...
9
35429
by: skinnybloke | last post by:
Hi - I have 3 access queries which I run via 1 macro. Each of the queries now requires 2 parameters when they the run. The parameters are start and end dates. I have built the parameters into the queries but on running the macro I have to enter each of the dates 3 times - once for each query. Is there an easy way to ask for the...
3
2155
by: Phil Stanton | last post by:
I have a number of queries which use code for the output of 1 or more fields. For example Address:GetAddress(AddressID, True, 60) Address ID Points to an Address in a table - Address Line1, Line 2, Line 3, Town, County, Post Code, Country. The True is whether to include the country and the 60 is the maximum line length (after which a line...
4
4565
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The...
0
7541
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7734
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7979
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5385
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5107
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1960
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1074
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.