public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch]: RM1171 - Fix IE caching issue
6+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
@ 2016-09-20 13:46  Surinder Kumar <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Surinder Kumar @ 2016-09-20 13:46 UTC (permalink / raw)
  To: pgadmin-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()
     )




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
@ 2016-09-20 13:55  Surinder Kumar <[email protected]>
  parent: Surinder Kumar <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Surinder Kumar @ 2016-09-20 13:55 UTC (permalink / raw)
  To: pgadmin-hackers

This patch has some issue in chrome while loading nodes. I will send
updated patch.

On Tue, Sep 20, 2016 at 7:16 PM, Surinder Kumar <
[email protected]> wrote:

> 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
>


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
@ 2016-09-20 13:58  Surinder Kumar <[email protected]>
  parent: Surinder Kumar <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Surinder Kumar @ 2016-09-20 13:58 UTC (permalink / raw)
  To: pgadmin-hackers

Missed method closing parenthesis while calling

Please find updated patch

On Tue, Sep 20, 2016 at 7:25 PM, Surinder Kumar <
[email protected]> wrote:

> This patch has some issue in chrome while loading nodes. I will send
> updated patch.
>
> On Tue, Sep 20, 2016 at 7:16 PM, Surinder Kumar <
> [email protected]> wrote:
>
>> 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_v1.patch (1.3K, 3-RM1171_v1.patch)
  download | inline diff:
diff --git a/web/pgadmin/utils/ajax.py b/web/pgadmin/utils/ajax.py
index 0e11eac..0c8ad56 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()
     )




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
@ 2016-09-21 12:29  Dave Page <[email protected]>
  parent: Surinder Kumar <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Page @ 2016-09-21 12:29 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers

Can you rebase please?

piranha:web dpage$ git apply ~/Downloads/RM1171_v1.patch
error: patch failed: web/pgadmin/utils/ajax.py:29
error: web/pgadmin/utils/ajax.py: patch does not apply

On Tue, Sep 20, 2016 at 2:58 PM, Surinder Kumar
<[email protected]> wrote:
> Missed method closing parenthesis while calling
>
> Please find updated patch
>
> On Tue, Sep 20, 2016 at 7:25 PM, Surinder Kumar
> <[email protected]> wrote:
>>
>> This patch has some issue in chrome while loading nodes. I will send
>> updated patch.
>>
>> On Tue, Sep 20, 2016 at 7:16 PM, Surinder Kumar
>> <[email protected]> wrote:
>>>
>>> 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
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
@ 2016-09-21 13:40  Surinder Kumar <[email protected]>
  parent: Dave Page <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Surinder Kumar @ 2016-09-21 13:40 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

​Hi

I did git pull and applied the patch without any error.​ I have attached
updated patch.
Please apply this patch and let me know if any issue.

On Wed, Sep 21, 2016 at 5:59 PM, Dave Page <[email protected]> wrote:

> Can you rebase please?
>
> piranha:web dpage$ git apply ~/Downloads/RM1171_v1.patch
> error: patch failed: web/pgadmin/utils/ajax.py:29
> error: web/pgadmin/utils/ajax.py: patch does not apply
>
> On Tue, Sep 20, 2016 at 2:58 PM, Surinder Kumar
> <[email protected]> wrote:
> > Missed method closing parenthesis while calling
> >
> > Please find updated patch
> >
> > On Tue, Sep 20, 2016 at 7:25 PM, Surinder Kumar
> > <[email protected]> wrote:
> >>
> >> This patch has some issue in chrome while loading nodes. I will send
> >> updated patch.
> >>
> >> On Tue, Sep 20, 2016 at 7:16 PM, Surinder Kumar
> >> <[email protected]> wrote:
> >>>
> >>> 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
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


-- 
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_v2.patch (1.3K, 3-RM1171_v2.patch)
  download | inline diff:
diff --git a/web/pgadmin/utils/ajax.py b/web/pgadmin/utils/ajax.py
index 0e11eac..0c8ad56 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()
     )




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [pgAdmin4][Patch]: RM1171 - Fix IE caching issue
@ 2016-09-21 15:19  Dave Page <[email protected]>
  parent: Surinder Kumar <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Dave Page @ 2016-09-21 15:19 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers

Thanks, applied.

On Wed, Sep 21, 2016 at 2:40 PM, Surinder Kumar
<[email protected]> wrote:
> Hi
>
> I did git pull and applied the patch without any error. I have attached
> updated patch.
> Please apply this patch and let me know if any issue.
>
> On Wed, Sep 21, 2016 at 5:59 PM, Dave Page <[email protected]> wrote:
>>
>> Can you rebase please?
>>
>> piranha:web dpage$ git apply ~/Downloads/RM1171_v1.patch
>> error: patch failed: web/pgadmin/utils/ajax.py:29
>> error: web/pgadmin/utils/ajax.py: patch does not apply
>>
>> On Tue, Sep 20, 2016 at 2:58 PM, Surinder Kumar
>> <[email protected]> wrote:
>> > Missed method closing parenthesis while calling
>> >
>> > Please find updated patch
>> >
>> > On Tue, Sep 20, 2016 at 7:25 PM, Surinder Kumar
>> > <[email protected]> wrote:
>> >>
>> >> This patch has some issue in chrome while loading nodes. I will send
>> >> updated patch.
>> >>
>> >> On Tue, Sep 20, 2016 at 7:16 PM, Surinder Kumar
>> >> <[email protected]> wrote:
>> >>>
>> >>> 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
>> >
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2016-09-21 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20 13:46 [pgAdmin4][Patch]: RM1171 - Fix IE caching issue Surinder Kumar <[email protected]>
2016-09-20 13:55 ` Surinder Kumar <[email protected]>
2016-09-20 13:58   ` Surinder Kumar <[email protected]>
2016-09-21 12:29     ` Dave Page <[email protected]>
2016-09-21 13:40       ` Surinder Kumar <[email protected]>
2016-09-21 15:19         ` Dave Page <[email protected]>

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