0

So on my site, I have some sliders which load videos from vimeo.

When I check on GTMetrix, I get a terrible amount of http requests. When I look at the waterfall, many of them are repeat download copies of the same javascript, css and swf files.

Is it possible with javascript to prevent the un-needed multiple copies from being downloaded in order to save load time and requests?

In some cases, theres 15+ copies of the same file being downloaded..

I've looked a bit, and don't really see a plugin to do something like I am asking.

Dan Smith
  • 533
  • 1
  • 6
  • 15

1 Answers1

0

You can ask your server to tell browsers they need to cache the files.

The configuration is different for different servers. If you use Apache, you could try this solution: https://stackoverflow.com/a/6878502/7655153

This is not something you can change on the client side, you need to change the server settings or (if your files are generated dynamically) your server-side code.

Community
  • 1
  • 1
  • 2
    He is asking "How to prevent duplicate requests?". – Sarvap Praharanayuthan Mar 04 '17 at 19:40
  • Even if it is cached, it won't download for each new request on the page? Because I have already set the browser caching. The issue here being primarily that it downloada a 400kb file from vimeo.com over 20 times... – Dan Smith Mar 04 '17 at 19:40
  • @DanSmith If it’s on Vimeo, then you can’t cache it, right... :D I can’t tell much without seeing the code, then. – Dzmitry Kushnarou Mar 04 '17 at 19:46
  • @ViswalingaSuryaS But if an asset is cached, it won’t be requested by the browser. Doesn’t this mean caching is a way to prevent duplicate requests? At least that’s how I understand it. – Dzmitry Kushnarou Mar 04 '17 at 19:47
  • Correct- I can't control thier htaccess in order to cache it.. but if I can make the page itself just not load the added ones.. – Dan Smith Mar 04 '17 at 19:47
  • @DanSmith It could be helpful if you could show the code you’re using to embed Vimeo videos. – Dzmitry Kushnarou Mar 04 '17 at 19:48
  • @DzmitryKushnarou, its a wordpress plugin, so the best I can do is show you this: view-source:http://abc.eliselondon.com/ – Dan Smith Mar 04 '17 at 19:53
  • Its all iframes – Dan Smith Mar 04 '17 at 19:54
  • 1
    I’m afraid you can’t do much about iFrame. It could be possible to switch to Vimeo’s JS API instead, but I don’t have experience with Vimeo and can’t help with that. Try adding a question specifically about optimizing Vimeo videos with a 'vimeo' tag, so that Vimeo wizards notice it. – Dzmitry Kushnarou Mar 04 '17 at 19:59