[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Images from database
Short Answer:
You need to correclty set the content type header to the appropriate mime
type for image display to work correclty. Expecting a browser ability to
adapt to unpredictable input and "do the right thing" is notoriously
unreliable. Have you tried it with Netscape 4.0, 4.5, 4.5.1, or 4.6? It is
likely that you will find slightly different behaviour under any one of 'em.
Same goes for IE.
Long Answer:
Storing images in the database is generally a bad idea for a whole slew of
reasons. First and foremost, it is loads slower than serving images directly
from the web server and it completely bypasses numerous automatic
"optmiziations" that are present when serving from a filesystem. If it can't
be avoided, it can't be avoided.... however, if you have any hopes of scaling
your solution to a large community of users or a heavy hit rate, expect to
expend a lot of engineering and hardware dollars making images-in-the-database
go fast.
Some random excerpts from previous postings (have a look at the archive of
the mailing list, this is a recurring discussion):
http://www.omnigroup.com/MailArchive/WebObjects/1998/1447.html
In particular:
Images are normally served statically from the filesystem... because you are
now serving them as dynamic content, the following performance hits occur:
- no client side caching [ouch] five copies of a single image on a page yields
five seperate hits on WO.
- image requests must be serialized-- not only do IMAGE hits have to be
serialized, but all other hits on the WOF app will have to wait for any
pending image hits to be handled. In terms of Netscape's REALLY SLOW table
layout algorithm that requires the size of all images to be known, this means
that the user WON'T see the contents of the table until ALL image hits have
returned at least the size of the image.... since hits are serialized, that
means that all but the last image must be entirely handled.
- performance difference between a static hit vs. a fully dynamic hit is
tremendous [in favor of static]. Think about it... a static hit basically
means the web server opens a file, reads/writes the contents to a socket,
closes... dynamic hits require IPC, a database round trip [maybe], a bunch of
memory munging, a pass through request/response, etc.etc.etc...
- no server side caching; every instance of your app will end up with a copy
of every image served in its memory. As well, the IPC between database and WO
app server will have to pass all that data back and forth, as well.
- most databases are not designed to handle BLOBs well.... regardless
Alternatives?
Stick a path in the filesystem in your database instead of a blob; abstract
arbitrarily to facilitate administration, etc...
If you REALLY need the images to come from the database, build an image
manager that maintains a hierarchy of the images in the filesystem and
arbitrates the updates between the database and the images.
One thought; if an image needs to be refreshed and you are worried about
client-side or proxying-firewall caching, rename the image in the filesystem
(or move it) and generate a new URL-- this should be the image managers
responsibility.
Of which, Mont Rothstein wrote an excellent set of questions:
http://www.omnigroup.com/MailArchive/WebObjects/1998/1451.html
That I replied to here:
http://www.omnigroup.com/MailArchive/WebObjects/1998/1452.html
There is more in the archive on this subject.... one thing that wasn't
mentioned in the various posts that is pertinent now is that images in the
database increase the transaction count to the WO application which can lead
to the requirement of a more expensive WO license. Most sites don't actually
need a $25k unlimited license-- at least, most don't until they have spent WAY
BEYOND that amount on bandwidth and other licesnes.... however, putting just
about every hit through your WO server will certainly increase the potential
WO cost.
b.bum
Simon Glet wrote:
> Hi,
>
> We would like to have all the site's images stored in our Oracle 7.3
> database. The problem is that the images are not displayed the same way by
> Explorer and Navigator.
>
> With Explorer 5 images are sometimes ok even if the mimeType of the WOImage
> is set to "whatever". Netscape 4.07 only displays the missing image icon.
>
> The database seems to have different type of stored images but how can I
> have the same behavior from the two browsers ? The two are set to load the
> images automatically.
>
> Thanks
> Simon Glet
> WebObjects Dev
> Inso, Montreal
> (514) 271-4676 ext 3388