-
Notifications
You must be signed in to change notification settings - Fork 194
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
550 cache busting #9447
550 cache busting #9447
Conversation
e13cf95
to
fe78e48
Compare
@@ -7,7 +7,7 @@ | |||
gds_organisation_id = "af07d5a5-df63-4ddc-9383-6a666845ebe9" | |||
User.create!( | |||
name: "Test user", | |||
permissions: ["signin", "GDS Admin", "GDS Editor", "Managing Editor", "Export data"], | |||
permissions: ["signin", "GDS Admin", "GDS Editor", "Managing Editor", "Export data", "Sidekiq Admin"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just add this for the Test User for good? I feel like it will continue to be useful as we continue to use Sidekiq...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can't see the harm 👍
@@ -51,6 +52,15 @@ def update_content_block_document(new_content_block_edition:, update_document_pa | |||
|
|||
private | |||
|
|||
def remove_cache_for_dependent_content(content_block_edition:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just realised I'm switching between dependent and host content... i've seen both used elsewhere, shall we stick with Host in the code as that's what we've got already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's stick with one or the other. I prefer dependent, but as host is used in a lot of places, let's use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, have changed to use host
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just one thing about the tests
@@ -51,6 +52,15 @@ def update_content_block_document(new_content_block_edition:, update_document_pa | |||
|
|||
private | |||
|
|||
def remove_cache_for_dependent_content(content_block_edition:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's stick with one or the other. I prefer dependent, but as host is used in a lot of places, let's use that.
timestamp = Time.zone.now.to_s | ||
publish_intent = { foo: "bar" } | ||
|
||
PublishingApi::PublishIntentPresenter.expects(:new).once.returns(publish_intent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check the arguments the presenter receives too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good spot, have done
We will shortly use this to add publishing intents for Documents that have embedded content in them, when the embedded content is updated and we do not want to wait the default 5 mins for the cache to update.
fe78e48
to
50733e1
Compare
When a content block is updated we do not want to wait the default cache time of 5 mins in order to see the changes in Documents that use this content block. Publish intents allow us to reset the cache time https://docs.publishing.service.gov.uk/repos/content-store/publish_intents.html
50733e1
to
c5b9360
Compare
This returns the publishing app name for all host editions (Editions with Embedded content in them) In this previous Whitehal PR [1] we send publish intents for host Documents of embedded content, but we hardcoded the publishing app to Whitehall - we need to see the correct publishing app for all host editions in order to send these intents. [1] alphagov/whitehall#9447
This returns the publishing app name for all host editions (Editions with Embedded content in them) In this previous Whitehal PR [1] we send publish intents for host Documents of embedded content, but we hardcoded the publishing app to Whitehall - we need to see the correct publishing app for all host editions in order to send these intents. [1] alphagov/whitehall#9447
we want to send Publish Intents for Host Content (e.g. Editions that are using embedded content/Content Blocks) [1] that is published by other apps - this allows an optional app to be passed in, but retains the default Whitehall value in order not to break existing functionality. [1] #9447
we want to send Publish Intents for Host Content (e.g. Editions that are using embedded content/Content Blocks) [1] that is published by other apps - this allows an optional app to be passed in, but retains the default Whitehall value in order not to break existing functionality. [1] #9447
we want to send Publish Intents for Host Content (e.g. Editions that are using embedded content/Content Blocks) [1] that is published by other apps - this allows an optional app to be passed in, but retains the default Whitehall value in order not to break existing functionality. [1] #9447
we want to send Publish Intents for Host Content (e.g. Editions that are using embedded content/Content Blocks) [1] that is published by other apps - this allows an optional app to be passed in, but retains the default Whitehall value in order not to break existing functionality. [1] #9447
When a content block is updated we do not want to wait the default cache time of 5 mins in order to see the changes in Documents that use this content block.
Publish intents allow us to reset the cache time for a Document
https://docs.publishing.service.gov.uk/repos/content-store/publish_intents.html
This PR creates a publish intent for any host Documents whenever a block is published.
I've put it at the point of publishing, rather than scheduling or updating, because we can instantly override the cache (or almost instantly depending on length of Sidekiq queue) whereas if we were to call it at point of scheduling, or only when we are updating, it gets a bit trickier to ensure that the method definitely gets called (we would also then have to cancel the intent if a scheduled Block was cancelled)
questions
I've put the PUT requests onto a Worker to be performed asynchronously as Whitehall do. I haven't stress tested this and would need help to do so if we wanted to do so- I'm not sure how slow it would be if a Block had 100-1000s of host Documents, but if it was slower then 5 mins the cache would be refreshed anyway.
To see locally
content-store
repo to see the cache time set for a content itempublish-intent
Follow these steps if you are doing a Rails upgrade.