<div dir="ltr">Hi Diego.<div><br></div><div>What you need to understand is how the server which you are embedding the content from works. It will not serve up the right content unless you give it the right Host: header (<a href="https://www.varnish-software.com/blog/getting-virtual-hosts-right-varnish-cache">https://www.varnish-software.com/blog/getting-virtual-hosts-right-varnish-cache</a> explain how virtual hosts actually works).</div>
<div><br></div><div>The thing you are missing is something like this:</div><div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">sub vlc_recv {<br></div><span style="font-family:arial,sans-serif;font-size:13px"> if (req.http.host ~ "</span><a href="http://infographics.estadaodados.com/" target="_blank" style="font-family:arial,sans-serif;font-size:13px">infographics.estadaodados.com</a><span style="font-family:arial,sans-serif;font-size:13px">") {</span></div>
<div> set req.http.host = "<a href="http://example.com">example.com</a>";</div><div> # could also override req.url here - but better to keep req.url the same (for simplicity).<br><span style="font-family:arial,sans-serif;font-size:13px"> set req.backend_hint = </span><span style="font-family:arial,sans-serif;font-size:13px">infograph;</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> }</span><br style="font-family:arial,sans-serif;font-size:13px"><div style="font-family:arial,sans-serif;font-size:13px"><div></div></div></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 11, 2014 at 8:10 PM, Diego Rabatone <span dir="ltr"><<a href="mailto:diraol@diraol.eng.br" target="_blank">diraol@diraol.eng.br</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>Hi James and Per,<br></div><br>thank you very much for answering my question.<br>
<br></div>First of all, I have the permission to embed the content. All embeds are from websites that are offer the service of building data visualizations and infographics, me and my team use them to build our products and they all have embeding options.<br>
<br></div>I like the option to only revalidate the contet, instead of refetching it, but I didn't understand completly how could I do it Per.<br><br></div>I will try and example, tell me if I'm making any conecptual mistake.<br>
<br></div>My cached domain is: <b><a href="http://estadaodados.com" target="_blank">estadaodados.com</a></b> , this is were I have full control and where my Varnish is.<br><br></div>On <b><a href="http://estadaodados.com/iframe" target="_blank">estadaodados.com/iframe</a></b> I want to embed, using an Iframe, a page from <b><a href="http://example.com" target="_blank">example.com</a></b>, exactly this page: <a href="http://example.com/123" target="_blank"><b>example.com/123</b></a><br>
<br></div><div>So, instead of using <i><iframe src="<a href="http://example.com/123" target="_blank">http://example.com/123</a>"></iframe></i><br></div>I should set <b><a href="http://example.com" target="_blank">example.com</a></b> as a <b>backend</b> on my varnish with:<br>
<br></div>backend infograph {<br></div> .host="<a href="http://example.com" target="_blank">example.com</a>"<br>}<br><br></div>And set this vcl_recv rule:<br><br></div>sub vlc_recv {<br></div> if (req.http.host ~ "<a href="http://infographics.estadaodados.com" target="_blank">infographics.estadaodados.com</a>") {<br>
set req.backend_hint = <a href="http://example.com" target="_blank">example.com</a><br> }<br><div><div><div><div><div><div><div><br><div>And then use the iframe with:<br><br></div><div><i><iframe src="<a href="http://infographics.estadaodados.com/123" target="_blank">infographics.estadaodados.com/123</a>"></iframe><br>
</i><br><br></div><div>That's it?<i><br></i></div><div><i><br></i></div><div><div><div>Thanks for your attention,<br><br>Best,<br><br></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra">
<div class="">
<br clear="all"><div>--------------------------------<br>Diego Rabatone Oliveira<br>diraol(arroba)diraol(ponto)eng(ponto)br<br>Identica: (@diraol) <a href="http://identi.ca/diraol" target="_blank">http://identi.ca/diraol</a><br>
Twitter: @diraol<br></div>
<br><br></div><div class="gmail_quote">2014-06-10 3:55 GMT-03:00 Per Buer <span dir="ltr"><<a href="mailto:perbu@varnish-software.com" target="_blank">perbu@varnish-software.com</a>></span>:<div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi Diego,<div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Tue, Jun 10, 2014 at 1:24 AM, Diego Rabatone <span dir="ltr"><<a href="mailto:diraol@diraol.eng.br" target="_blank">diraol@diraol.eng.br</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi friends,<br><br></div>I am new at the caching World, and I have looked for some solution to cross-domain caching, but I have not found any solution.<br>
<br></div>I have a blog that embed some dataviz webservices, and I want to cache this content that I insert using Iframes.<br>
</div>The blog is: <a href="http://blog.estadaodados.com" target="_blank">http://blog.estadaodados.com</a> there is any way of doing this?<br></div></div></blockquote><div><br></div></div><div>Absolutely. It is a pretty good way to make sure that the content you embed performs well in addition to lessening the load on the server you are embedding content from.</div>
<div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">At this moment I have a Varnish + nginx + php-fpm setup on a dev server (not the link that I posted), and it seems to be working ok, but there is no caching of the Iframes.<br>
</div></blockquote><div><br></div></div><div>No. This is expected. In order to cache those iframes you would need to set up the server you embedding content from as a backend on your varnish and preferably give it a new hostname. Then, in the vcl_recv you replace req.http.host to the original hostname and set the backend. Then regular caching rules will be applied. In Varnish 4.0 you could set the cache time to one hour and you could add a keep of maybe a couple of hours. That will enable IMS so you wouldn't have to refetch the content, only revalidate it.</div>
<div><br></div><div><br></div><div>As James said, should make sure you have the authors permission, but if you do it through Varnish at least there won't be much of a impact on their server when you do this.</div><div>
<br></div><div>Cheers,</div><div><br></div><div>Per.</div></div><span><font color="#888888"><div><br></div>-- <br><div dir="ltr"><div style="font-size:12.727272033691406px;margin:5px 15px 0px 0px;padding-bottom:5px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">
<table style="text-align:start;font-size:12px;line-height:1.5em;font-family:'Helvetica Neue',Arial,sans-serif;color:rgb(102,102,102);width:550px;border-top-width:1px;border-top-style:solid;border-top-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);margin-top:20px;padding-top:5px;padding-bottom:5px" border="0" cellpadding="0" cellspacing="0">
<tbody><tr><td style="font-family:arial,sans-serif;margin:0px" width="100"><a href="http://www.varnish-software.com/" style="color:rgb(17,85,204)" target="_blank"><img src="http://www.varnish-software.com/static/media/logo-email.png" style="float:left;margin-left:10px"></a></td>
<td style="font-family:arial,sans-serif;margin:0px"><b style="font-size:14px;color:rgb(34,34,34)">Per Buer</b><br>CTO | Varnish Software<br>Phone: <a href="tel:%2B47%20958%2039%20117" value="+4795839117" target="_blank">+47 958 39 117</a> | Skype: per.buer<br>
<span style="font-weight:bold">We Make Websites Fly!<br>
<br></span><span style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:14px;font-weight:bold">Winner of the Red Herring Top 100 Global Award 2013<br></span><p style="margin:0px;line-height:normal;font-family:Helvetica">
<img src="https://www.varnish-software.com/sites/default/files/redherring_2013_winner_sml.jpg"></p><span style="font-weight:bold"><br></span></td></tr></tbody></table><div></div></div><div style="font-size:12.727272033691406px;margin:15px 0px;clear:both;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">
</div></div>
</font></span></div></div>
</blockquote></div></div></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div style="font-size:12.727272033691406px;margin:5px 15px 0px 0px;padding-bottom:5px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">
<table border="0" cellpadding="0" cellspacing="0" style="text-align:start;font-size:12px;line-height:1.5em;font-family:'Helvetica Neue',Arial,sans-serif;color:rgb(102,102,102);width:550px;border-top-width:1px;border-top-style:solid;border-top-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);margin-top:20px;padding-top:5px;padding-bottom:5px">
<tbody><tr><td width="100" style="font-family:arial,sans-serif;margin:0px"><a href="http://www.varnish-software.com/" style="color:rgb(17,85,204)" target="_blank"><img src="http://www.varnish-software.com/static/media/logo-email.png" style="float:left;margin-left:10px"></a></td>
<td style="font-family:arial,sans-serif;margin:0px"><b style="font-size:14px;color:rgb(34,34,34)">Per Buer</b><br>CTO | Varnish Software<br>Phone: +47 958 39 117 | Skype: per.buer<br><span style="font-weight:bold">We Make Websites Fly!<br>
<br></span><span style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:14px;font-weight:bold">Winner of the Red Herring Top 100 Global Award 2013<br></span><p style="margin:0px;line-height:normal;font-family:Helvetica">
<img src="https://www.varnish-software.com/sites/default/files/redherring_2013_winner_sml.jpg"></p><span style="font-weight:bold"><br></span></td></tr></tbody></table><div></div></div><div style="font-size:12.727272033691406px;margin:15px 0px;clear:both;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">
</div></div>
</div>