ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
552 stars 52 forks source link

possibly-invalid cache behavior for 404 responses #225

Closed buhman closed 6 years ago

buhman commented 6 years ago

Despite having thought this was completely correct for years, clearly it is not.

originally reported in https://github.com/HalosGhost/pbpst/issues/90

[tw-mbp-zbuhman ~]$ curl -F c=@- https://ptpb.pw <<< 'this is my test'
date: 2018-08-16T17:16:15.094000+00:00
digest: 3c21bf30b1a7456ffb85481148bb943c85a24926
long: ADwhvzCxp0Vv-4VIEUi7lDyFokkm
short: okkm
size: 16
status: already exists
url: https://ptpb.pw/okkm
[tw-mbp-zbuhman ~]$ curl -D- https://ptpb.pw/okkm
HTTP/1.1 404 NOT FOUND
Server: openresty/1.13.6.2
Date: Thu, 16 Aug 2018 17:26:03 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 18
Connection: keep-alive
Vary: Accept
ETag: "paste-5afca108921db93306efb8ad002ffbf42ec867b6"
Cache-Control: max-age=43200, public
X-Varnish: 8961173 6661799
Age: 599
Via: 1.1 varnish-v4

status: not found

There are two (non-exclusive) possibilities to fix this:

buhman commented 6 years ago

verified fixed due to 51b091a6bf12ae9f96d6a6da55d3d1dd8ee183cd

➜  ~ curl -F c=@- https://ptpb.pw <<< 'invalidate on post'              
date: 2018-08-17T05:12:41.737957+00:00
digest: 54635e7e83c68ad31edf47be7812429243c943ff
long: AFRjXn6DxorTHt9HvngSQpJDyUP_
short: yUP_
size: 19
status: created
url: https://ptpb.pw/yUP_
uuid: 702eda1c-1abe-4ada-919b-4fdc9e0b9fc3
➜  ~ curl -X DELETE https://ptpb.pw/702eda1c-1abe-4ada-919b-4fdc9e0b9fc3
date: 2018-08-17T05:12:41.737000+00:00
digest: 54635e7e83c68ad31edf47be7812429243c943ff
long: AFRjXn6DxorTHt9HvngSQpJDyUP_
short: yUP_
size: 19
status: deleted
url: https://ptpb.pw/yUP_
➜  ~ curl https://ptpb.pw/yUP_
status: not found
➜  ~ curl -F c=@- https://ptpb.pw <<< 'invalidate on post'              
date: 2018-08-17T05:13:18.571185+00:00
digest: 54635e7e83c68ad31edf47be7812429243c943ff
long: AFRjXn6DxorTHt9HvngSQpJDyUP_
short: yUP_
size: 19
status: created
url: https://ptpb.pw/yUP_
uuid: 05c39cc8-49af-4362-b1a4-493fdc25ae71
➜  ~ curl https://ptpb.pw/yUP_                            
invalidate on post
buhman commented 6 years ago

@BurhanDanger thanks for the report!

BurhanDanger commented 6 years ago

wow, That was fast.