Solved

How to make images cache in a e-commerce sites

Posted on 2013-12-30
4
281 Views
Last Modified: 2014-01-03
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. ?
0
Comment
Question by:rdm4u
  • 2
4 Comments
 
LVL 9

Expert Comment

by:David Carr
ID: 39748346
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.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39748415
This will depend on your HTTP server (?) on how you set the expiry date for assets.
0
 
LVL 4

Author Comment

by:rdm4u
ID: 39754561
That may be a http server settings. Is there any other way to set the expiry time on dynamic images/js ?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39754583
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>
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Every business owner understands the significance of online customer reviews and the impact it can have on sales and revenues. With technology advancing at such a rapid pace, getting online reviews has never been easier, especially when many regions…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now