angularjs - Clear cache on page refresh using javaScript or jquery - Stack Overflow

My Webpageworks fine when it loads the first time but when i click refresh button or reload page it

My Webpage / works fine when it loads the first time but when i click refresh button or reload page it won't load fully(The into part the transition of mobile and stuff) specially in Chrome, if i press ctrl + f5 it'll work fine

so i want to clear cache whenever page refresh or reload is done or is there any better solution for this

i tried the following code but it keeps loading the page

    <script>
      window.onload = function() {
      if(!window.location.hash) {
       window.location = window.location + '#loaded';
       window.location.reload();
      }
    }
    </script>

My Webpage http://avocettechnologies./avocetiq/ works fine when it loads the first time but when i click refresh button or reload page it won't load fully(The into part the transition of mobile and stuff) specially in Chrome, if i press ctrl + f5 it'll work fine

so i want to clear cache whenever page refresh or reload is done or is there any better solution for this

i tried the following code but it keeps loading the page

    <script>
      window.onload = function() {
      if(!window.location.hash) {
       window.location = window.location + '#loaded';
       window.location.reload();
      }
    }
    </script>

`

My Website is in angularjs

Thank You

Share Improve this question edited Aug 12, 2016 at 11:19 Mr Robot asked Aug 12, 2016 at 8:07 Mr RobotMr Robot 8975 gold badges21 silver badges47 bronze badges 3
  • please explain a bit more because "page won't load fully" is not enough to answer this question. Try to post some more relevant code. – Yogesh Commented Aug 12, 2016 at 8:42
  • I think you would be better implementing a correct caching mechanism, rather than manually trying to refresh the cache every single time. Set correct caching headers for your different resources. You will want to cache 3rd party JS/CSS for example. Set correct expires headers. And set no-cache on resources you dont want the browsers to cache. Caching can great improve the Users Experience of your site, and reduce the load on your servers etc. Browser cache is no longer the only option either now. – ste2425 Commented Aug 12, 2016 at 9:18
  • @ste2425, yogesh I have updated the post with website url, in home page the intro trasition will work fine but not after refresh or reload, – Mr Robot Commented Aug 12, 2016 at 10:56
Add a ment  | 

1 Answer 1

Reset to default 5

By default, the reload() method reloads the page from the cache, but you can force it to reload the page from the server by :

location.reload(true)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744369990a4570898.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信