0

I'm using Twitter Bootstrap and in my code I display a modal with the remote option that point to an external HTML file. The HTML file is loaded fine and the modal is displayed fine. The problem is that once I make a change to the html file and fire it up again it doesn't load the change until I delete the browser cache.

This is my code:

$('#modal').modal({
    remote: baseUrl + 'Content/templates/speedtest.html'
});

speedtest contains the following:

<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">Title</h4>
        </div>
        <div class="modal-body">
            My Message
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
    </div>
</div>

During development it's very unusful since I want to make a change to the html and then see that change quickly without having to delete the cache.

Also, I'm afraid that after uploading the site if I make changes to the html, visitors will get irrelevant results.

How can I disable/configure the cache?

Thanks

madth3
  • 7,275
  • 12
  • 50
  • 74
developer82
  • 13,237
  • 21
  • 88
  • 153
  • repeat http://stackoverflow.com/questions/12286332/twitter-bootstrap-remote-modal-shows-same-content-everytime – Farkhat Mikhalko Feb 12 '14 at 08:33
  • @FUserThrowError - this is not the same case. The question you referred to is about opening while the browser is still on the same page and just changing the remote option. I'm talking about a single modal that even after the browser was closed and re-opened doesn't give me an updated html. – developer82 Feb 12 '14 at 08:38
  • 2
    `$.ajaxSetup({ cache: false });` might help – Dale Feb 12 '14 at 08:42
  • @Dale - thanks. but, while it did help, it causes ajax parts of my website where I do want to use caching not to be cached. is there a solution to that? – developer82 Feb 12 '14 at 08:45
  • if you're running a specific ajax call you can add `cache: true` as a property of the options object to not cache that particular call – Dale Feb 12 '14 at 08:59
  • @Dale I'm not running the call - bootstrap does – developer82 Feb 12 '14 at 09:29

1 Answers1

0

I have a solution is so easy, add new Date().getTime() on end.

$('#modal').modal({
  remote: baseUrl + 'Content/templates/speedtest.html?'+new Date().getTime()
});
Hutch
  • 1