-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete organigram in model before exchanging #1090
base: master
Are you sure you want to change the base?
Delete organigram in model before exchanging #1090
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1090 +/- ##
==========================================
- Coverage 87.64% 87.63% -0.02%
==========================================
Files 1185 1185
Lines 77924 77939 +15
==========================================
Hits 68300 68300
- Misses 9624 9639 +15 ☔ View full report in Codecov by Sentry. |
@Daverball I found when exchanging the organigram attachement I need to delete the |
You can probably use |
Not sure if disabling the cache globally is the best idea, I was more thinking of setting headers in individual views. Although if it's just the standard file view (i.e. the organigram doesn't use its own view) the flaw might be in |
I found Events do not have the issue when replacing the image. So l looked into it. The difference is |
You can delete the file and generate a new one so the link changes, but setting the last modified header seems like a more permanent solution, since this affects all uploaded files and not just this one. See here for how we set the last modified header in election day: onegov-cloud/src/onegov/election_day/utils/common.py Lines 59 to 69 in 1fb9395
You should be able to retrieve the last modified from either the file reference, or you can use the timestamp on the file model which should also change when the reference changes. The file view is here: onegov-cloud/src/onegov/file/integration.py Lines 486 to 490 in 1fb9395
It might be worth adding a onegov-cloud/src/onegov/election_day/views/election/main.py Lines 28 to 42 in 1fb9395
|
Unfortunately the 'last-modified' response header did not resolve the issue although it was set correctly. A regular refresh did not reload the image resource, see last commit. The root cause, in my opinion, is the resource (organigram) does not get a new id when exchanging the image. if i delete first, then add a new organigram I get a new resource id hence a proper page reload. I suggest to go back to my original attempt which ends up in a new resource id upon exchanging the organigram. |
You need to set it in the file view not the view that links to the file, the file is a separate request, setting it on the html does absolutely nothing, since that isn't cached to begin with (unless you manually enable it through cache control headers), that's why i pointed you towards the file view and not the agency view. This is also why I said it affects all files and not just the ones in agency. So this issue will crop up again and again unless we fix it correctly. |
After moving the I also found that the |
@Tschuppi81 It might have something to do with that we're also setting max age on the It's also possible that bjoern does some file caching of its own, to speed up file requests, of which there are usually many. In which case I guess we can rely on the workaround. |
Also you might need to add the last modified header to be present in the file view as well, so the browser has a frame of reference. Since the head view calls the file view, you should just be able to move the function that sets the last modified header to the file view. |
No, I still don't see any head views calls when removing max age... I also did various changes regarding caching, changing the headers. Nothing helped there as the file view does not get called for after editing the organigram of an So I started to investigate on the different behavior and found the After changing the
to
it starts working, independent of caching changes. |
I'd like to investigate this myself at some point, but I guess there's also the issue of I don't mind changing the behavior to replace the file entirely in this specific case, although I'd do a git blame on it to investigate whether this branch has been added intentionally to fix another bug, or if maybe the branch used to be there in the other model and was removed for the same reason. |
Agency: Fixes required forced browser refresh (Ctrl+F5) after organigram replacement
TYPE: Bugfix
LINK: ogc-1346