473,432 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

SSI vs. reading in a file vs. caching a DB entry?

I have bits of content on a site that's running of a basic CMS system I've
built.

The main content on each page is pulled in from the DB, so there's at least
one call to the DB on each page load.

But then there's content like the page footer, which is rarely updated, and
is the same on every page.

Since this is rarely updated, but initial thought was to store it in the DB,
but whenever it is edited, spit it out as a text file. Then I could use SSI
and just include it on all of the pages. The problem with the include is
that I want to include it on a usercontrol, and IIRC, the controls are
executed prior to includes, so instead, I can use a objStreamReader to read
in the file.

My first question is if reading a file via objStreamReader is any different
performance-wise than using server side includes?

My second question is if I should instead consider using an actual DB call
to grab the data, but then setting it in a session state. That way it is
only called once per user per session, and then stored in memory from page
to page. Or does that matter?

-Darrel
Nov 19 '05 #1
5 1303
Darrell:

Turn the footer into a user control and use 'fragment caching', which is
simply adding a Cache directive to the user control. This is easier than
using the file system.

See: http://msdn.microsoft.com/library/de...aspnetpage.asp
--
Scott
http://www.OdeToCode.com/blogs/scott/
I have bits of content on a site that's running of a basic CMS system
I've built.

The main content on each page is pulled in from the DB, so there's at
least one call to the DB on each page load.

But then there's content like the page footer, which is rarely
updated, and is the same on every page.

Since this is rarely updated, but initial thought was to store it in
the DB, but whenever it is edited, spit it out as a text file. Then I
could use SSI and just include it on all of the pages. The problem
with the include is that I want to include it on a usercontrol, and
IIRC, the controls are executed prior to includes, so instead, I can
use a objStreamReader to read in the file.

My first question is if reading a file via objStreamReader is any
different performance-wise than using server side includes?

My second question is if I should instead consider using an actual DB
call to grab the data, but then setting it in a session state. That
way it is only called once per user per session, and then stored in
memory from page to page. Or does that matter?

-Darrel

Nov 19 '05 #2
> Turn the footer into a user control and use 'fragment caching', which is
simply adding a Cache directive to the user control. This is easier than
using the file system.
See:

http://msdn.microsoft.com/library/de...aspnetpage.asp

Actually, the filesystem method seemed pretty easy. ;o)

I see a few catches with using the regular Cache settings for this type of
thing, though. One, if the person wants to update this content, they have to
wait for the cache to expire to see the change. If the cache is only a few
seconds, no big deal, but if if it's 5 minutes, that gets to be a bit
impractical. And, if it's only a few seconds, it doesn't really seem worth
it, as I'll still be hitting the database later on.

The other issue is that I'm loading the footer control dynamically and it
will load different content based on what ASPX page i'm looking at. So I
don't think I want to cache a control that will behave different from aspx
page to aspx page, do I?

-Darrel
Nov 19 '05 #3
Yes, with those additional requirements you might want to look at the Cache
object (to cache the file's contents) and the CacheDependency class (which
can invalidate a cache entry when the file changes). This would give you
flexibility, the most up to date content, and still avoid reprocessing the
file on each request.

--
Scott
http://www.OdeToCode.com/blogs/scott/
Turn the footer into a user control and use 'fragment caching', which
is
simply adding a Cache directive to the user control. This is easier
than
using the file system.
See:

http://msdn.microsoft.com/library/de...ry/en-us/cpgui
de/html/cpconcachingportionsofaspnetpage.asp

Actually, the filesystem method seemed pretty easy. ;o)

I see a few catches with using the regular Cache settings for this
type of thing, though. One, if the person wants to update this
content, they have to wait for the cache to expire to see the change.
If the cache is only a few seconds, no big deal, but if if it's 5
minutes, that gets to be a bit impractical. And, if it's only a few
seconds, it doesn't really seem worth it, as I'll still be hitting the
database later on.

The other issue is that I'm loading the footer control dynamically and
it will load different content based on what ASPX page i'm looking at.
So I don't think I want to cache a control that will behave different
from aspx page to aspx page, do I?

-Darrel

Nov 19 '05 #4
> Yes, with those additional requirements you might want to look at the
Cache
object (to cache the file's contents) and the CacheDependency class (which
can invalidate a cache entry when the file changes). This would give you
flexibility, the most up to date content, and still avoid reprocessing the
file on each request.


Will do.

That said, am I overthinking all of this? Is reading in a text file really
any different performance wise than a plain-ol' SSI? We've used tons of SSIs
in the past without servers crashing so perhaps I'm worrying about a
miniscule amount of processing time.

-Darrel
Nov 19 '05 #5
The problem I had with SSI was maintainability - which is ironic since SSI
was touted for it's ability to make ASP more maintainable (but those were
the ASP days).

With abstractions like user controls you can approach the design in an object
oriented fashion, hide additional complexity, and have a more flexible design.
I know this is a very vague, sky-high, hand waving assertion, but to give
you a bit of a concrete example, look at Karl's article:
http://openmymind.net/communication/index.html

In terms of processing time - it might not be a big win either way.

--
Scott
http://www.OdeToCode.com/blogs/scott/
Yes, with those additional requirements you might want to look at the

Cache
object (to cache the file's contents) and the CacheDependency class
(which can invalidate a cache entry when the file changes). This
would give you flexibility, the most up to date content, and still
avoid reprocessing the file on each request.

Will do.

That said, am I overthinking all of this? Is reading in a text file
really any different performance wise than a plain-ol' SSI? We've used
tons of SSIs in the past without servers crashing so perhaps I'm
worrying about a miniscule amount of processing time.

-Darrel

Nov 19 '05 #6

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

Similar topics

3
by: Fredrik Normann | last post by:
Hello, I'm trying to read the binary files under /var/spool/rwho/ so I'm wondering if anyone has done that before or could give me some clues on how to read those files. I've tried to use the...
0
by: Eric Lilja | last post by:
Hello, I have a text file that contains a number of entries describing a recipe. Each entry consists of a number of strings. Here's an example file with only one entry (recipe): Name=Maple Quill...
3
by: Michel de Becdeličvre | last post by:
I have some *performance* trouble reading MathML files in my application (in ASP.Net). - I have small MathML files (2-3k) as input - as (almost) all MathML files these use entities. I have no...
3
by: Darrel | last post by:
I've been working on a fairly simple CMS for a fairly small site. Each page is a DB query to grab the content for the page. I also have some ancillary content that isn't specifically associated...
10
by: BillGatesFan | last post by:
I'm trying to understand ASP.NET caching. I set the Page Output directive to VaryByParams= None and the duration = 60. Now whenever users hit my web app they can see each others data. Is there...
0
by: Brian | last post by:
I've deployed a 'URL rewriter' version of our application almost two months ago and it is working great (.NET 1.1, Win2k, IIS5). Since then, I've gotten just FOUR exceptions that look like this: ...
4
by: Craig Vermeer | last post by:
Hi All, I have a program that's using the file system as a queuing mechanism, and it's consuming an inordinate amount of CPU time when the file system queue gets all that large (any more than a...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: Laharl | last post by:
My Operating Systems professor has assigned homework that basically boils down to implementing ls -lra, but with a different output format. In other words, list the files and subdirectories (and a...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.