0

Hi,

im currently testing the website i created. i used a method of displaying the image through FileStream and BinaryReader (e.g "http://localhost/img.aspx?id=test.jpg"). it works fine actually, but the thing is, everytime i navigate through pages the image reload as well, taking a hit on the page load time.

question:
is there a way to cache the image. so once it's loaded before, it won't stream anymore and will use the cache instead? thanks and hope someone could help me.

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by dnanetwork
0

r u loading data using .ashx ?

if no then you can cache the querystring...
depend on that it will cache the image..!

put this on the page level..
<@outputcache varybyParam="id" duration="time of your choice">

Edited by dnanetwork: n/a

0

im loading data via aspx Page Load response. i'll check if this is applicable. will try first :)

0

still looks the same. the picture still load page after page. :| the code of aspx file is this:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="img.aspx.vb" Inherits="user_img" %>
<%@ OutputCache VaryByParam="id" Duration="3600" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>

then on the page load:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.QueryString("id") IsNot Nothing Then
                DisplayImage(Request.QueryString("id"))
        End If
    End Sub

DisplayImage is the file streamer :)

i did it right? yes?

0

yes u did right but to check the o/p
you need to enable trace option at page level;

so you can see if the page is cached..!

Edited by dnanetwork: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.