Skip to content
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

Refreshing after publishing can cause old page version being served #2330

Closed
pascalbetz opened this issue May 5, 2022 · 1 comment
Closed

Comments

@pascalbetz
Copy link
Contributor

Hello Alchemy Team

We are upgrading to 6.0 and stumbled over this issue. Unfortunately we are not yet on upstream (but hopefully soon) but from reading the code it seems that this is a problem of Alchemy and not our fork.

Happy to help with fixing this, please let me know if my proposed solution is the way to go.

Steps to reproduce

  • Disable background jobs, so thePublishPageJob is not running
  • Change content, save, publish page
  • Visit page: old content is server
  • Start background jobs, wait until PublishPageJob is processed
  • Visit page: still old content is server

I assume this is because upon publication Page#publish! is called, which updates the published_at timestamp and then defers the rest of the work to the (new) background job.

This timestamp is used when calculating etag/stale status of a page. So if a request is made between (depending on the load on the job queueu and the popularity of the page, this happening is quite likely) updating the timestamp and running the job, then the old page version is served with the new etag already.

Proposal: Moving the update of the published_at timestamp to the Publisher#publish would fix this, though i don't know if there are any unwanted consequences with this.

Expected behavior

Updated page content is served, once job has been processed

Actual behavior

Old page cpontent is served

System configuration

  • Alchemy Version: 6
  • Rails Version: 6.1
pascalbetz added a commit to algrano/alchemy_cms that referenced this issue May 5, 2022
@tvdeyen
Copy link
Member

tvdeyen commented May 5, 2022

Thanks for reporting. The proposed solution makes total sense. Could you add some tests and open a PR? Thank you

dbwinger pushed a commit to dbwinger/alchemy_cms that referenced this issue Mar 20, 2023
Closes  AlchemyCMS#2330

Updating published_at only after a public PageVersion has been created or updated
to avoid e-tags being created with old PageVersion.

re-add Page#publish! since it was public interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants