Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Lionsanime Directory   Improve your ranking, submit to directories   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 10-26-2006, 10:36 AM   #1 (permalink)
Inactive
 
Join Date: 10-26-06
Posts: 3
iTrader: 0 / 0%
Latest Blog:
None

alecks is liked by many
Force Caching of Images but not the page (asp)

Hello,

I've been researching this all week and haven't found a good solution.
I run a website where artists can upload their artwork and add it to a huge collaborative piece (www.cre18.com/canvas.asp).

The site is dynamically driven; uses asp to get submited cells and renders them to the page. the images are file based (not stored in the DB).

How can I force caching metadata or headers on IMAGES ONLY, but not the page that serves the images (art.asp)
if I put caching headers on art.asp, then it won't load new images as they are submitted.

I just want to force all the art images (say 1_1.jpg, 1_2.jpg, etc...) to be cached longer

I thought about writing an image serving script that reads each file and does a binary write. Something like :
instead of <img src="art/1_1.jpg">
do: <img src="getimg.asp?1_1.jpg">
and set the headers on getimg.asp, but would this round-about method be slower or cause too much overhead, whith all those FileSystemObjects loading up

Any thoughts would be greatly appreciated.

Thanks
-Alex
alecks is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 10-27-2006, 09:56 AM   #2 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Although caching is up to the browser, and caching headers are typically used to allow/disallow that behavior, you may be able to 'force' caching of the images by preloading them using a client-side script ... i.e. tell the browser to fetch them before they are requested from within the page code.

The same principal applies to the ol' onmouseover Javascript image swapping trick:
Code:
1_1 = new Image(); 1_1.src = "images/1_1.png"; ..etc..
then reference the script variables while populating your page:
Code:
for (i=0;i<=imgs.length-1;i++) { curr_img=imgs[i]; curr_alt=alts[i]; document.write("<img src='"+curr_img.src+"' alt='"+curr_alt+"' />"); }
where imgs is an array of the image references to be used and alts is an array of, say, artist info corresponding to each image.

Just winging it ...

Last edited by StupidScript : 10-27-2006 at 10:10 AM.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2006, 12:30 PM   #3 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Boy. Looking at the site is a little mind-boggling. How many images are you expecting to deliver with each request? How 'big' will your canvas get?

IMHO, your least-resource-intensive method for continuing to develop this site would be to change from file-based to a blobbed-database structure. (a) This would immediately overcome the caching problem you describe, as each image would be drawn from a live database on demand with each request and (b) a few connections to the database per visitor would be a lot less "spendy" for the server than multiple http connections per visitor, which would bog things down pretty quickly when your traffic levels get high enough.

That project is going to push your resources to the max, sooner or later, regardless of which delivery method you choose. There's lots of big images in there, and even from my T3 connection it took awhile to fully load.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2006, 01:31 PM   #4 (permalink)
Inactive
 
Join Date: 10-26-06
Posts: 3
iTrader: 0 / 0%
Latest Blog:
None

alecks is liked by many
Quote:
Originally Posted by StupidScript View Post
Boy. Looking at the site is a little mind-boggling. How many images are you expecting to deliver with each request? How 'big' will your canvas get?

IMHO, your least-resource-intensive method for continuing to develop this site would be to change from file-based to a blobbed-database structure. (a) This would immediately overcome the caching problem you describe, as each image would be drawn from a live database on demand with each request and (b) a few connections to the database per visitor would be a lot less "spendy" for the server than multiple http connections per visitor, which would bog things down pretty quickly when your traffic levels get high enough.

That project is going to push your resources to the max, sooner or later, regardless of which delivery method you choose. There's lots of big images in there, and even from my T3 connection it took awhile to fully load.

Hi,

Thanks for your feedback. I've been thinking about the db solution and it just seems very counter intuitive.
If the images are stored as Blobs, then, as you suggested, every pageview will force all that data to be sent to the browser, whereas if the images are cached, only the first time is all the data transfered to the client. subsequent visits will use the cached images UNTIL they expire. And that's what I was essentially asking how to do, force a longer than default expiration date.

"T3 connection it took awhile to fully load." Was it better the 2nd time you visited? I think hitting refresh, on some browsers, it forces a 'get all' regardless of what's cached, fyi.


The canvas will grow as large as possible. The project is essentially infinite, technical challenges aside.
One idea I had was to develop a google-maps like interface, where it loads new images as they are scrolled to towards them, but that's a bit beyond my current coding abilities.
alecks is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2006, 01:46 PM   #5 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Aaahh. Gotcha. So ... neither of my suggestions are on the right track! LOL!

This clearly requires more thought than I have given it ... Complicated doesn't begin to describe the programming that will be required ... soon. Hmmm ...
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
page select for images on external CSS navyfalcon Coding Forum 7 09-22-2007 02:13 AM
Apache 2.0 -- Conditional caching of .css .js and images c-low Dedicated Servers 0 07-30-2007 11:21 AM
Admin page - Uploading images Rod Coding Forum 3 06-28-2007 12:53 PM
Images Alignment on Page problem. HELP leeuniverse Coding Forum 2 07-12-2006 03:40 AM
Images on page show as [AD-SIZE] Ricoool Web Design Lobby 0 10-16-2003 06:08 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 06:51 PM.
© Copyright 2008 V7 Inc