* [review-request][PATCH 1/3] toaster: Don't add new history entries when table data loads
2015-10-01 9:33 [review-request][PATCH 0/3][v2] Prevent stale data in ToasterTables Elliot Smith
@ 2015-10-01 9:33 ` Elliot Smith
2015-10-01 9:33 ` [review-request][PATCH 2/3] toaster: Don't HTTP cache ToasterTable responses Elliot Smith
2015-10-01 9:33 ` [review-request][PATCH 3/3] toaster: Don't store table data in the browser Elliot Smith
2 siblings, 0 replies; 5+ messages in thread
From: Elliot Smith @ 2015-10-01 9:33 UTC (permalink / raw)
To: toaster
When ToasterTable data is loaded into the UI, a new entry is
added to the browser history. This means that pressing the back
button appears to have no effect, as you end up at the same page,
possibly with slightly different data.
Instead, use replaceState(), so that the browser history doesn't
grow, but the page context still gets updated.
[YOCTO #7660]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
bitbake/lib/toaster/toastergui/static/js/table.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js
index f18034d..99b99a0 100644
--- a/bitbake/lib/toaster/toastergui/static/js/table.js
+++ b/bitbake/lib/toaster/toastergui/static/js/table.js
@@ -49,7 +49,7 @@ function tableInit(ctx){
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
success: function(tableData) {
updateTable(tableData);
- window.history.pushState({
+ window.history.replaceState({
tableData: tableData,
tableParams: tableParams
}, null, libtoaster.dumpsUrlParams(tableParams));
--
Elliot Smith
Software Engineer
Intel OTC
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related [flat|nested] 5+ messages in thread* [review-request][PATCH 2/3] toaster: Don't HTTP cache ToasterTable responses
2015-10-01 9:33 [review-request][PATCH 0/3][v2] Prevent stale data in ToasterTables Elliot Smith
2015-10-01 9:33 ` [review-request][PATCH 1/3] toaster: Don't add new history entries when table data loads Elliot Smith
@ 2015-10-01 9:33 ` Elliot Smith
2015-10-01 9:33 ` [review-request][PATCH 3/3] toaster: Don't store table data in the browser Elliot Smith
2 siblings, 0 replies; 5+ messages in thread
From: Elliot Smith @ 2015-10-01 9:33 UTC (permalink / raw)
To: toaster
Django allows generated pages to be cached by default by the
browser. This can result in stale data displaying for some pages.
Instead, disable HTTP caching of ToasterTable responses, so that
each time a ToasterTable view is displayed, its data is
refreshed. This carries a performance penalty, but ensures that
ToasterTable views (e.g. compatible layers) are correctly
refreshed if the user navigates their history with forward/back.
[YOCTO #7660]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
bitbake/lib/toaster/toastergui/widgets.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py
index e58dd7c..6bb3889 100644
--- a/bitbake/lib/toaster/toastergui/widgets.py
+++ b/bitbake/lib/toaster/toastergui/widgets.py
@@ -20,6 +20,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.views.generic import View, TemplateView
+from django.views.decorators.cache import cache_control
from django.shortcuts import HttpResponse
from django.http import HttpResponseBadRequest
from django.core import serializers
@@ -64,6 +65,11 @@ class ToasterTable(TemplateView):
orderable=True,
field_name="id")
+ # prevent HTTP caching of table data
+ @cache_control(must_revalidate=True, max_age=0, no_store=True, no_cache=True)
+ def dispatch(self, *args, **kwargs):
+ return super(ToasterTable, self).dispatch(*args, **kwargs)
+
def get_context_data(self, **kwargs):
context = super(ToasterTable, self).get_context_data(**kwargs)
context['title'] = self.title
--
Elliot Smith
Software Engineer
Intel OTC
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related [flat|nested] 5+ messages in thread* [review-request][PATCH 3/3] toaster: Don't store table data in the browser
2015-10-01 9:33 [review-request][PATCH 0/3][v2] Prevent stale data in ToasterTables Elliot Smith
2015-10-01 9:33 ` [review-request][PATCH 1/3] toaster: Don't add new history entries when table data loads Elliot Smith
2015-10-01 9:33 ` [review-request][PATCH 2/3] toaster: Don't HTTP cache ToasterTable responses Elliot Smith
@ 2015-10-01 9:33 ` Elliot Smith
2015-10-06 16:08 ` Michael Wood
2 siblings, 1 reply; 5+ messages in thread
From: Elliot Smith @ 2015-10-01 9:33 UTC (permalink / raw)
To: toaster
As table data is no longer loaded from the history stack
(it's refreshed from the server on navigation), remove
the onpopstate event handler and the code which pushes
the page data onto the stack.
[YOCTO #7660]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
bitbake/lib/toaster/toastergui/static/js/table.js | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js
index 99b99a0..b30b552 100644
--- a/bitbake/lib/toaster/toastergui/static/js/table.js
+++ b/bitbake/lib/toaster/toastergui/static/js/table.js
@@ -33,14 +33,6 @@ function tableInit(ctx){
loadData(tableParams);
- window.onpopstate = function(event){
- if (event.state){
- tableParams = event.state.tableParams;
- /* We skip loadData and just update the table */
- updateTable(event.state.tableData);
- }
- };
-
function loadData(tableParams){
$.ajax({
type: "GET",
@@ -49,10 +41,6 @@ function tableInit(ctx){
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
success: function(tableData) {
updateTable(tableData);
- window.history.replaceState({
- tableData: tableData,
- tableParams: tableParams
- }, null, libtoaster.dumpsUrlParams(tableParams));
}
});
}
--
Elliot Smith
Software Engineer
Intel OTC
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [review-request][PATCH 3/3] toaster: Don't store table data in the browser
2015-10-01 9:33 ` [review-request][PATCH 3/3] toaster: Don't store table data in the browser Elliot Smith
@ 2015-10-06 16:08 ` Michael Wood
0 siblings, 0 replies; 5+ messages in thread
From: Michael Wood @ 2015-10-06 16:08 UTC (permalink / raw)
To: toaster
Just for the record this patch set was submitted upstream (I updated the
wrong thread)
Michael
On 01/10/15 10:33, Elliot Smith wrote:
> As table data is no longer loaded from the history stack
> (it's refreshed from the server on navigation), remove
> the onpopstate event handler and the code which pushes
> the page data onto the stack.
>
> [YOCTO #7660]
>
> Signed-off-by: Elliot Smith <elliot.smith@intel.com>
> ---
> bitbake/lib/toaster/toastergui/static/js/table.js | 12 ------------
> 1 file changed, 12 deletions(-)
>
> diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js
> index 99b99a0..b30b552 100644
> --- a/bitbake/lib/toaster/toastergui/static/js/table.js
> +++ b/bitbake/lib/toaster/toastergui/static/js/table.js
> @@ -33,14 +33,6 @@ function tableInit(ctx){
>
> loadData(tableParams);
>
> - window.onpopstate = function(event){
> - if (event.state){
> - tableParams = event.state.tableParams;
> - /* We skip loadData and just update the table */
> - updateTable(event.state.tableData);
> - }
> - };
> -
> function loadData(tableParams){
> $.ajax({
> type: "GET",
> @@ -49,10 +41,6 @@ function tableInit(ctx){
> headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
> success: function(tableData) {
> updateTable(tableData);
> - window.history.replaceState({
> - tableData: tableData,
> - tableParams: tableParams
> - }, null, libtoaster.dumpsUrlParams(tableParams));
> }
> });
> }
^ permalink raw reply [flat|nested] 5+ messages in thread