Solved

How to make images cache in a e-commerce sites

Posted on 2013-12-30
4
283 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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With a software solution, you always get to control email signatures and have the final say on the design - not an unrelated department or the uninterested end user.
Read about why website design really matters in today's demanding market.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

911 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

16 Experts available now in Live!

Get 1:1 Help Now