Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is faster? Include or Link rel?

0 views
Skip to first unread message

MJ

unread,
Jan 25, 2002, 11:17:37 AM1/25/02
to
Hi
What is faster?
Include CSS (Style sheets) file with ASP
<!-- #include file="Common/style.css" -->
or
is it faster to use in the header of HTML document
<LINK REL=stylesheet HREF="common/style.css" TYPE="text/css">?

Currently I am using <Link Rel.....> but I was wondering if I might gain
some speed using #include to include the whole file in the page before it is
send to the browser. (the page is heavily used - over 100 000 a month)
The similar question could be asked probably about Javascript files...
Does anybody did any testing or knows where to find an answer?
Thanks
MJ


Aaron Bertrand [MVP]

unread,
Jan 25, 2002, 11:17:16 AM1/25/02
to
Probably depends on your hardware, how much data is in the CSS file, etc.
You can test:

http://www.aspfaq.com/show.asp?id=2092
http://www.aspfaq.com/show.asp?id=2139


"MJ" <skl...@hotmail.com> wrote in message
news:uD0XgtbpBHA.1856@tkmsftngp04...

Scott Wilson

unread,
Jan 25, 2002, 11:32:29 AM1/25/02
to
Using #Include will add that code to your page Server Side - The Browser
will Always receive it. Using the <Link> tag will add the code to your page
Client Side - The Browser appends the file itself. This also means that the
browser will Cache the file seperately - End result, once the file is
downloaded, it doesn't have to be redownloaded again. In conclusion, <link>
is definatley faster.

Scott

"MJ" <skl...@hotmail.com> wrote in message
news:uD0XgtbpBHA.1856@tkmsftngp04...

Aaron Bertrand [MVP]

unread,
Jan 25, 2002, 11:36:33 AM1/25/02
to
> Using #Include will add that code to your page Server Side - The Browser
> will Always receive it. Using the <Link> tag will add the code to your
page
> Client Side - The Browser appends the file itself. This also means that
the
> browser will Cache the file seperately - End result, once the file is
> downloaded, it doesn't have to be redownloaded again. In conclusion,
<link>
> is definatley faster.

I don't think it's that clear-cut. With the LINK tag, the browser has to
make a second request to the server. Which, in some cases (most noticeably
with lower-speed dialups), is significantly slower than receiving all the
bytes in the stream of one request. Also, the browser won't necessarily
cache the files, depending on the user's individual settings.

www.aspfaq.com


Rowland Shaw

unread,
Jan 28, 2002, 4:14:05 AM1/28/02
to
"Aaron Bertrand [MVP]" <aaronATaspfaq.com> wrote...


True, there will be an overhead on the initial request, but when the CSS is
common to many files, it can (and will) be cached by browsers and
intermediary caches, meaning the origin server need not be contacted again.

Example:
http://www.didcot.com/ - 18k without CSS
http://www.didcot.com/styles.css - 7k of CSS

I then browse to, say, http://www.didcot.com/eatndrink/ 5k of doc needs to
be requested, but the 7k of CSS is already here.

The HTTP overhead is in the order of less than 1k per request (significantly
less in most cases)

To use the same worked example but with CSS inline:
http://www.didcot.com/ - would be 25k
http://www.didcot.com/eatndrink/ - would be 12k
Or to put it another way, 7k more (before HTTP overhead, which, as we
already said, would be less than a k)

There may be some users who have changed from the default setting of their
browser to always fetch the latest version; but even those can be twarted by
intermediary caches.

In short, it's better for the web server to do them separatly, than together
all the time.

There are other issues, but most of them vanish into obscurity compared to
the size of the data. (like CPU overhead of including the file server side)


0 new messages