Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set cache-control to external resources?

@tools.pingdom.com I get a warning in leverage cache-control because of these resources:

http://code.jquery.com/jquery-1.6.2.min.js
http://www.google-analytics.com/ga.js
http://edge.sharethis.com/images/spinner.gif
http://w.sharethis.com/button/buttons.js

Which are not in my host.

What can I do about this?

This is the beginning of my htaccess:

# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>

# 1 weeks
<FilesMatch "\.(js)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
like image 365
Toni Michel Caubet Avatar asked Mar 06 '12 08:03

Toni Michel Caubet


People also ask

How do I set Cache-Control to public?

To use cache-control in HTML, you use the meta tag, e.g. The value in the content field is defined as one of the four values below. HTTP 1.1. Allowed values = PUBLIC | PRIVATE | NO-CACHE | NO-STORE.

How do you set Cache-Control for static content?

Here is what you need to remember while caching static resources on CDN or local cache server: Use Cache-control HTTP directive to control who can cache the response, under which conditions, and for how long. Configure your server or application to send validation token Etag. Do not cache HTML in the browser.

How do you define Cache-Control?

Cache-control is an HTTP header used to specify browser caching policies in both client requests and server responses. Policies include how a resource is cached, where it's cached and its maximum age before expiring (i.e., time to live).


2 Answers

You can't control the headers sent from a server that you don't control.

In other words, either host a copy yourself or there's nothing you can do about it.

like image 75
Corbin Avatar answered Oct 03 '22 07:10

Corbin


You can grab the code from the resources and serve them from your site directly, in these way you can manage the cache, but if some update occurs from the sites related to the resources, you miss it, or you have to control everytime ..chose at your convenience.

like image 41
onlinecasinoselite Avatar answered Oct 03 '22 07:10

onlinecasinoselite