HTML Cache External Images Only

Posted on 2012-12-25
Last Modified: 2012-12-25
In process of trying to optimize the recommendation we are getting from google's page speed insights ( is to leverage caching.

What meta tag do we need to use to specify caching images (local and external) longer (say 3 months) and caching the HTML of the page for only a week?

The goal is to leverage public cache pools by using
Question by:ullfindsmit
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
LVL 17

Expert Comment

ID: 38720359
It's not a META tag.

Its a server Issue  or setting

If you use IIS

LVL 12

Author Comment

ID: 38720364
Unfortunately some (or even a good majority) of the images come from third party servers that I have no control over
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38720365
Image files don't have META tags or any other HTML in them.  That would have to be done on the server.  Here's a page about doing in Apache:  I don't know how to set this up in IIS.  I that in the other comment.

If they're from third party servers, there is nothing you can do about it.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 12

Author Comment

ID: 38720372
So is there an HTML tag on the HTML page that I can use to say cache this page and its contents (local and external images) for 7 days?
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38720376
LVL 17

Accepted Solution

selvol earned 500 total points
ID: 38720395
Depending on your need to do this.

I'll just put this out  here.  
I have used this in the past.
What is does is takes an external Image and makes it local..
Create this page on your server in the root DIR and Name it extimage.php
NO Spaces BEFORE this.

<?php header('Content-type: image/jpg') ; 
$external_image = file_Get_contents($_GET['url']);
echo $external_image; ?>

Open in new window

Link to it like so

Open in new window

To add it into HTML would be like


Regards SELvol
LVL 12

Author Closing Comment

ID: 38720611
While it aint pretty, it does the job
LVL 17

Expert Comment

ID: 38720736
Glad You appreciate that script....

Who needs pretty, when your sneaky.

You could Save the external image to a local FOlder.
 Add a Check to see if the File exists before the PHP
gets the external Image.

Regards Selvol

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

690 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