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

suggestion from #9338: add some command/option to the deploy command to refresh the version #9915

Merged
merged 7 commits into from
Jun 15, 2017

Conversation

AntonEvers
Copy link
Contributor

@AntonEvers AntonEvers commented Jun 12, 2017

Description

@ishakhsuvarov suggested to replace PR #9338 with an option to the bin/magento setup:static-content:deploy command that only updates the version of the generated files.
This is in favour of editing the pub/static/deployed_version.txt manually.

This comes in handy when a CDN server is out-of-sync or when you want to hotfix a file in deployed code and you want to force a browser cache refresh. This buys you time to deploy the hotfix in a proper way at a moment that is better suited for downtime.

Fixed Issues (if relevant)

  1. Make deployed_version.txt editor friendly #9338

Manual testing scenarios

  1. bin/magento setup:static-content:deploy -f --content-version="123456" --refresh-content-version-only
  2. No deployment will take place, but the version is now 123456

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Anton Evers and others added 3 commits June 11, 2017 12:59
In production environments with a CDN for static files it comes in handy that you can force a browser cache refresh by changing the number manually without having to go into maintenance for a full deploy.

If you edit the `pub/static/deployed_version.txt` with vim, nano or `echo '123456789' > pub/static/deployed_version.txt` you can unintentionally create a newline at the end of the file.
This will result in:

```html
    var BASE_URL = 'https://magento2.dev/sitemanager/admin/index/index/key/ec38dd3ded42b71db14166d6bcdfc56d4e7d4b7801b9808373ae4b3563b65513/';
    var FORM_KEY = 'dKArsQU6NhimXr6Z';
    var require = {
        "baseUrl": "https://magento2.dev/pub/static/version1492766286
/adminhtml/Magento/backend/en_US"
    };
```

With that baseUrl all resources using baseUrl will return the 404 page.

Adding a simple `trim()` here will remove that risk.
With this option you can quickly force a browser cache refresh or
a CDN cache refresh without having to generate all static content.

This comes in handy especially when you have made no code changes,
but the CDN failed to update it's cache the last time you deployed
or when you have made a manual change in one of the static files
as a hotfix on your deployment server, awaiting a suitable moment
for deployment to finalize it.

This reopens magento#9338.
@ishakhsuvarov ishakhsuvarov self-assigned this Jun 12, 2017
@ishakhsuvarov ishakhsuvarov added this to the June 2017 milestone Jun 12, 2017
@AntonEvers
Copy link
Contributor Author

@ishakhsuvarov I will fix the unit test today

@magento-team magento-team merged commit 9de25f5 into magento:develop Jun 15, 2017
magento-team pushed a commit that referenced this pull request Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants