public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
Date: Tue, 20 Sep 2016 19:16:41 +0530
Message-ID: <CAM5-9D90JkDMwj+AqJQZGbpyHJdfy6Z6w2s7EtH3vGP7tmvapQ@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi

*Issue:*
IE always caching the response data returned from the server and when same
request is made for next time, it doesn't bring new data, instead it use
cached data.

*Solution:*
Set cache to '*no-cache*' in response headers while sending from the server
side. This prevents browser from caching data every time an http request is
made.

Thanks to Harshal & Murtaza for discussing issue and solution.

Please find attached patch and review.


Thanks,
Surinder Kumar


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM1171.patch (1.3K, 3-RM1171.patch)
  download | inline diff:
diff --git a/web/pgadmin/utils/ajax.py b/web/pgadmin/utils/ajax.py
index 0e11eac..3ab3f3d 100644
--- a/web/pgadmin/utils/ajax.py
+++ b/web/pgadmin/utils/ajax.py
@@ -29,6 +29,18 @@ class DataTypeJSONEncoder(json.JSONEncoder):

         return json.JSONEncoder.default(self, obj)

+def get_no_cache_header():
+    """
+    Prevent browser from caching data every time an
+    http request is made.
+    Returns: headers
+    """
+    headers = {}
+    headers["Cache-Control"] = "no-cache, no-store, must-revalidate"  # HTTP 1.1.
+    headers["Pragma"] = "no-cache"  # HTTP 1.0.
+    headers["Expires"] = "0"  # Proxies.
+    return headers
+

 def make_json_response(
         success=1, errormsg='', info='', result=None, data=None, status=200
@@ -45,7 +57,8 @@ def make_json_response(
     return Response(
         response=json.dumps(doc, cls=DataTypeJSONEncoder),
         status=status,
-        mimetype="application/json"
+        mimetype="application/json",
+        headers=get_no_cache_header
     )


@@ -54,7 +67,8 @@ def make_response(response=None, status=200):
     return Response(
         response=json.dumps(response, cls=DataTypeJSONEncoder),
         status=status,
-        mimetype="application/json"
+        mimetype="application/json",
+        headers=get_no_cache_header()
     )




view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
  In-Reply-To: <CAM5-9D90JkDMwj+AqJQZGbpyHJdfy6Z6w2s7EtH3vGP7tmvapQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox