Link to home
Start Free TrialLog in
Avatar of Ramdas Mayya
Ramdas MayyaFlag for United States of America

asked on

How to make images cache in a e-commerce sites

We are using a windows server to serve the images to our e-commerce site. The images are fetched using a flat url. and there is no set time out used in image tags.
So the images are being downloaded every next day if somebody accesses our site.

We may use some scene7 server  or akamai kind of CDNs to cache our content. But I would like to know if there a way we can set time for caching static resources like image/css/js etc?

Or is there any other possible solution to download image from a server and make use of browser caching. ?
Avatar of David Carr
David Carr
Flag of United States of America image

Here is some code you can put in your HTML in the <head> section
<script type="text/javascript">

<!-- hide from non JavaScript Browsers

Pic1= new Pic
pic1.src = "pic1.jpg"

Pic2 = new Pic
Pic2.src = "pic2.jpg"

// End Hiding -->
</script>

Open in new window


You can specify the height and width of the images by adding dimensions after new Pic ie.New Pic(150,150).

Add other images as needed and increment with Pic 3, Pic 4 etc.
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ramdas Mayya

ASKER

That may be a http server settings. Is there any other way to set the expiry time on dynamic images/js ?
What exactly do you mean by dynamic? Dynamically generated?
It shouldn't make any difference, it is still an image/file

Is this on IIS or Apache? PHP or .net...?

If IIS just amend the web.config like so to cache for 30 days

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
    </staticContent>
  </system.webServer>
</configuration>