Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / November 2007



Tip: Looking for answers? Try searching our database.

Faster response?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo Roberto - 25 Nov 2007 22:55 GMT
Hi, the only way for listing images from db is the below? Can it be faster?
because it is listing slowly the images...

<img src="adm/picture.asp?ID=<%response.write RS("ID")%>" width="145"
height="109" align="top" class="style1">

and the picture.asp:

<!-- #include file="connection.asp" -->
<%
 Dim ID
 ID = Request.QueryString("ID")

 Dim Conn, rsImagem, SQL
 SQL = "SELECT filedata FROM Tbladd WHERE ID = " & ID

 Set Conn = Server.CreateObject("ADODB.Connection")

 Conn.Open MM_editora_STRING
 Set rsImagem = Server.CreateObject("ADODB.Recordset")
 rsImagem.Open SQL, Conn

 Response.ContentType = "image/jpg"

 Response.BinaryWrite rsImagem("filedata")

 rsImagem.Close
 Set rsImagem = Nothing
 Conn.Close
 Set Conn = Nothing
%>

Thanks!
Anthony Jones - 27 Nov 2007 10:21 GMT
> Hi, the only way for listing images from db is the below? Can it be faster?
> because it is listing slowly the images...
[quoted text clipped - 27 lines]
>   Set Conn = Nothing
> %>

One option is stop storing them in the DB.

One of the reasons this will appear slow is the every time the image is
needed its is retrieved from the server.  If you must store them in the DB
store set Expires and CacheControl properties of the response and add an
ETag header to uniquely identify the version of the image (although at this
stage any value for ETag would do).

Now the client can use fresh content in its cache to supply JPGs rather than
fetching from the server all the time.

If you're Images may change frequently then add a unique value field to the
tbladd and ensure that this value is changed very time the image is changed.
Its the value of this field you would as a ETag header.  Now you can set the
expiry and cache-control to use a short period of caching.  When a request
comes in compare the ETag header in the request with the unique value in the
table.  If then set the response Expiry and CacheControl properties as you
would have but then:-

Response.Status = "304 Not Modified"
Response.End

Signature

Anthony Jones - MVP ASP/ASP.NET

Paulo - 27 Nov 2007 12:35 GMT
How can I do the inverse? Extract from ole field to file ? Is it possible to
be done?

Thanks man!

>> Hi, the only way for listing images from db is the below? Can it be
> faster?
[quoted text clipped - 56 lines]
> Response.Status = "304 Not Modified"
> Response.End
Anthony Jones - 27 Nov 2007 16:11 GMT
> >> Hi, the only way for listing images from db is the below? Can it be
> > faster?
[quoted text clipped - 61 lines]
>
> Thanks man!

'Uncomment if necessary
'Const adTypeBinary = 1
'Const adSaveCreateOverWrite = 2

Set mstream = Server.CreateObject("ADODB.Stream")
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rsImagem("filedata").Value
mstream.SaveToFile Server.MapPath("/images/" & ID & ".jpg"),
adSaveCreateOverWrite

Your code will need write access to the images folder of your website.

Signature

Anthony Jones - MVP ASP/ASP.NET

Paulo - 27 Nov 2007 16:15 GMT
Thanks man, I'll try it!

Bye!

>> >> Hi, the only way for listing images from db is the below? Can it be
>> > faster?
[quoted text clipped - 81 lines]
>
> Your code will need write access to the images folder of your website.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.