{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/14815","repository_url":"https://api.github.com/repos/angular/angular.js","labels_url":"https://api.github.com/repos/angular/angular.js/issues/14815/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/14815/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/14815/events","html_url":"https://github.com/angular/angular.js/issues/14815","id":161660944,"number":14815,"title":"svg <use> xlink combined with ngIf cache issue","user":{"login":"felixruponen","id":5947704,"avatar_url":"https://avatars.githubusercontent.com/u/5947704?v=3","gravatar_id":"","url":"https://api.github.com/users/felixruponen","html_url":"https://github.com/felixruponen","followers_url":"https://api.github.com/users/felixruponen/followers","following_url":"https://api.github.com/users/felixruponen/following{/other_user}","gists_url":"https://api.github.com/users/felixruponen/gists{/gist_id}","starred_url":"https://api.github.com/users/felixruponen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixruponen/subscriptions","organizations_url":"https://api.github.com/users/felixruponen/orgs","repos_url":"https://api.github.com/users/felixruponen/repos","events_url":"https://api.github.com/users/felixruponen/events{/privacy}","received_events_url":"https://api.github.com/users/felixruponen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-22T11:47:25Z","updated_at":"2016-06-23T10:33:59Z","closed_at":"2016-06-23T10:33:59Z","body":"**What is the current behavior?**\r\nWhen using an svg use tag like `<svg><use xlink=\"someSvgSprite.svg#someId\"></svg>` inside a ngIf block a new network request for 'someSvgSprite.svg' is issued every time the ngIf is toggled \r\nto true and the svg is re-rendered.\r\n\r\n**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).**\r\n\r\n1. Create container tag with ngIf=\"someToggleFlag\" that contains two svg use:xlink elements\r\n2. Record network activity in Chrome\r\n3. Toggle the someToggleFlag to false and true again\r\n4. The network activity should now show one more fetch for the svg sprite\r\n\r\nI have created this plnkr to show the behaviour:\r\n\r\nhttp://plnkr.co/edit/2Jy6nXQsf2XC0bfQi4qW?p=preview\r\n\r\nJust open network tab in chrome inspector and press the toggle button to hide/show two of the icons and watch the icons.svg file be loaded every time the icons get shown again.\r\n\r\n**What is the expected behavior?**\r\nThe expected behaviour is that the 'someSvgSprite.svg' is only fetched once.\r\n\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\nSvg use:xlink should work with ngIf.\r\n\r\n\r\n**Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.**\r\nTested this in Chrome v. 51.0.2704.103 with Angular 1.5.5, not sure if this is an Angular bug\r\nor a bug in Chrome since it works as expected in Firefox ie. the 'someSvgSprite.svg' is\r\nonly fetched once.\r\n\r\n\r\n**Other information (e.g. stacktraces, related issues, suggestions how to fix)**\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/228011618","html_url":"https://github.com/angular/angular.js/issues/14815#issuecomment-228011618","issue_url":"https://api.github.com/repos/angular/angular.js/issues/14815","id":228011618,"user":{"login":"Narretz","id":1153097,"avatar_url":"https://avatars.githubusercontent.com/u/1153097?v=3","gravatar_id":"","url":"https://api.github.com/users/Narretz","html_url":"https://github.com/Narretz","followers_url":"https://api.github.com/users/Narretz/followers","following_url":"https://api.github.com/users/Narretz/following{/other_user}","gists_url":"https://api.github.com/users/Narretz/gists{/gist_id}","starred_url":"https://api.github.com/users/Narretz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narretz/subscriptions","organizations_url":"https://api.github.com/users/Narretz/orgs","repos_url":"https://api.github.com/users/Narretz/repos","events_url":"https://api.github.com/users/Narretz/events{/privacy}","received_events_url":"https://api.github.com/users/Narretz/received_events","type":"User","site_admin":false},"created_at":"2016-06-23T10:33:59Z","updated_at":"2016-06-23T10:33:59Z","body":"I'm pretty sure this is due to different browser cache implemenations - note that the same happens when you put the icons.svg in an img tag. The .svg doesn't have any caching set (Cache-Control:no-cache in response header), so it actually sounds correct that the browser gets the same image again. Note that Firefox doesn'T actually make a request - so the behavior must be in some layer that is deeper than http caching.\r\n\r\nAfaict, the same happens without Angular: http://plnkr.co/edit/mJG33dAXI7BRavUwqoDq?p=preview"}}
{"actor":{"display_login":"Narretz"}}