Faster response?

Faster response?

am 25.11.2007 23:55:23 von Paulo Roberto

Hi, the only way for listing images from db is the below? Can it be faster?
because it is listing slowly the images...

" width="145"
height="109" align="top" class="style1">

and the picture.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!

Re: Faster response?

am 27.11.2007 11:21:36 von Anthony Jones

"Paulo Roberto" wrote in message
news:ezogia7LIHA.5244@TK2MSFTNGP03.phx.gbl...
> Hi, the only way for listing images from db is the below? Can it be
faster?
> because it is listing slowly the images...
>
> " width="145"
> height="109" align="top" class="style1">
>
> and the picture.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
> %>
>

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



--
Anthony Jones - MVP ASP/ASP.NET

Re: Faster response?

am 27.11.2007 13:35:44 von PaulO

How can I do the inverse? Extract from ole field to file ? Is it possible to
be done?

Thanks man!

"Anthony Jones" escreveu na mensagem
news:eeCtL9NMIHA.2140@TK2MSFTNGP03.phx.gbl...
> "Paulo Roberto" wrote in message
> news:ezogia7LIHA.5244@TK2MSFTNGP03.phx.gbl...
>> Hi, the only way for listing images from db is the below? Can it be
> faster?
>> because it is listing slowly the images...
>>
>> " width="145"
>> height="109" align="top" class="style1">
>>
>> and the picture.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
>> %>
>>
>
> 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
>
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>

Re: Faster response?

am 27.11.2007 17:11:44 von Anthony Jones

"Paulo" wrote in message
news:OfBJNIPMIHA.4584@TK2MSFTNGP03.phx.gbl...
> "Anthony Jones" escreveu na mensagem
> news:eeCtL9NMIHA.2140@TK2MSFTNGP03.phx.gbl...
> > "Paulo Roberto" wrote in message
> > news:ezogia7LIHA.5244@TK2MSFTNGP03.phx.gbl...
> >> Hi, the only way for listing images from db is the below? Can it be
> > faster?
> >> because it is listing slowly the images...
> >>
> >> " width="145"
> >> height="109" align="top" class="style1">
> >>
> >> and the picture.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
> >> %>
> >>
> >
> > 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
> >
> >
> >
> > --
> > Anthony Jones - MVP ASP/ASP.NET
> >
> >
>
> How can I do the inverse? Extract from ole field to file ? Is it possible
to
> be done?
>
> 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.


--
Anthony Jones - MVP ASP/ASP.NET

Re: Faster response?

am 27.11.2007 17:15:47 von PaulO

Thanks man, I'll try it!

Bye!

"Anthony Jones" escreveu na mensagem
news:u72G1ARMIHA.5140@TK2MSFTNGP05.phx.gbl...
>
> "Paulo" wrote in message
> news:OfBJNIPMIHA.4584@TK2MSFTNGP03.phx.gbl...
>> "Anthony Jones" escreveu na mensagem
>> news:eeCtL9NMIHA.2140@TK2MSFTNGP03.phx.gbl...
>> > "Paulo Roberto" wrote in message
>> > news:ezogia7LIHA.5244@TK2MSFTNGP03.phx.gbl...
>> >> Hi, the only way for listing images from db is the below? Can it be
>> > faster?
>> >> because it is listing slowly the images...
>> >>
>> >> " width="145"
>> >> height="109" align="top" class="style1">
>> >>
>> >> and the picture.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
>> >> %>
>> >>
>> >
>> > 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
>> >
>> >
>> >
>> > --
>> > Anthony Jones - MVP ASP/ASP.NET
>> >
>> >
>>
>> How can I do the inverse? Extract from ole field to file ? Is it possible
> to
>> be done?
>>
>> 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.
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>