Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force Firefox to bypass BFCache for Angular.JS partials?

I'm working on an Angular.js page and making changes to an html 'partial'. Refreshing the page causes Firefox to correctly re-request the main html page from the server, but subsequent 'partial' templates that are rendered client-side are never re-requested and instead grabbed from the BFCache, so changes to those files aren't detected.

Screenshot from Firebug: BFCache firebug screenshot

I can confirm via the development server (Django) that those partials are never requested.

I've tried every kind of refresh, including the Reload Plus extension.

like image 642
GDorn Avatar asked Apr 14 '15 19:04

GDorn


2 Answers

These are less than ideal, but two options appear to address the problem.

One is the Clear Cache addon, which can be configured to clear disk and memory cache and reload the current tab. I'm not sure if this clears the cache completely or just for the current tab's domain, but it's probably the entire cache.

The other is to disable the browser cache in firebug:firebug disable cache

I'm not sure if this simply disables the cache for the current page, current domain, or everywhere.

It'd still be nice to have a 'Reload this page and everything referenced by this page' option.

like image 126
GDorn Avatar answered Nov 16 '22 01:11

GDorn


I would just set a flag in your templates to add a simple onunload function like this:

{% if CLEARBFCACHE %} <body onunload="myFunction()"> {% endif %}

Then set CLEARBFCACHE = 1 (in settings.py) when in development.

If you need to test for production set CLEARBFCACHE = 0 then deploy to your staging server or (if you don't have a separate server) I believe you can change the url from 127.0.0.1 to locahost to make Firefox think it's a different site.

like image 21
Charlie Avatar answered Nov 16 '22 02:11

Charlie