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

Add header: Accept-Ranges 'bytes' to super-cache expert mode .htaccess #27748

Closed
wants to merge 5 commits into from
Closed

Add header: Accept-Ranges 'bytes' to super-cache expert mode .htaccess #27748

wants to merge 5 commits into from

Conversation

hirasso
Copy link
Contributor

@hirasso hirasso commented Dec 5, 2022

Related thread on the forums: https://wordpress.org/support/topic/add-accept-ranges-header-to-htaccess/

I am making heavy use of link prefetching on one of my websites. In the article about prefetching on MDN they mention, that, if the response header contains Accept-Ranges: bytes, a partially loaded resource can be re-used from the browser cache.

Changes proposed in this Pull Request:

During the generation of the .htaccess file for super-caches expert mode, This header directive is being injected:

Header set Accept-Ranges 'bytes'

Other information:

Since this PR only targets super-cache, I haven't set-up the full jetpack environment. Just symlinked the plugin to my plugins folder as described and tested the new directive injection manually. Works fine for me.

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Disabling the cache and re-enabling it re-generates the .htaccess file and injects the new directive. Before:

image

After:

image

@github-actions github-actions bot added the [Plugin] Super Cache A fast caching plugin for WordPress. label Dec 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.



Super Cache plugin:

  • Next scheduled release: January 3, 2023.
  • Scheduled code freeze: December 26, 2022.

@github-actions github-actions bot added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! OSS Citizen This Pull Request was opened by an Open Source contributor. labels Dec 5, 2022
@hirasso
Copy link
Contributor Author

hirasso commented Dec 7, 2022

What does "Needs Author Reply" mean? Am I the author or the Authors of this plugin?

I'm a bit overwhelmed by all these bots, maybe someone can help? :)

@jeherve jeherve added the [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it label Dec 9, 2022
@jeherve
Copy link
Member

jeherve commented Dec 9, 2022

Thanks for your contribution!

What does "Needs Author Reply" mean? Am I the author or the Authors of this plugin?

I'm a bit overwhelmed by all these bots, maybe someone can help? :)

In this case, the author would be you, the author of the PR. As you can see in the checks running below, there are a few things that you will need to fix in your branch before this PR can be merged:

  • You would need to run git pull && git merge origin/trunk to update your branch to be up to date.
  • There are some linting issues you would need to fix. They are listed here. You'll see that some of those issues existed before your suggested changes, but since you are making changes to that line, we're now taking that opportunity to fix the problems.

Thank you!

@hirasso
Copy link
Contributor Author

hirasso commented Dec 9, 2022

Thanks @jeherve for your help.

git pull && git merge origin/trunk returns "Already up to date" for me.

Regarding the linting: Should I run this on the whole monorepo or only on super-cache? Which scripts would I need to run excactly? prettier and phpcs? It would probably be quicker if someone who knows what they are doing would do these things, instead of trying to hold my hand through this 🙏

@jeherve
Copy link
Member

jeherve commented Dec 9, 2022

git pull && git merge origin/trunk returns "Already up to date" for me.

Sorry, I may have wrongly assumed your local setup. What do you get when you run git remote -v locally? Does origin refer to your own fork, git@github.com:hirasso/jetpack.git, or to the main repository git@github.com:automattic/jetpack.git?

  • If the former, and if you do not have the main repository as a remote yet, try running git remote add upstream git@github.com:automattic/jetpack.git && git fetch upstream && git merge upstream/trunk
  • If the latter, could you try running git fetch origin && git merge origin/trunk?

Regarding the linting: Should I run this on the whole monorepo or only on super-cache? Which scripts would I need to run excactly? prettier and phpcs?

You do not need to run any scripts for this. You should be able to manually make the changes that are highlighted as errors here:
https://github.com/Automattic/jetpack/pull/27748/files#diff-49e24876fd767aa7d12d7018a180f19e42dc62b47484a137fe4d42fdb31d10f6R1049

It would probably be quicker if someone who knows what they are doing would do these things, instead of trying to hold my hand through this 🙏

If that doesn't work out for you, let me know and I'll make the changes in your branch for you.

@hirasso
Copy link
Contributor Author

hirasso commented Dec 9, 2022

Thank you!! I'll try my best. If that's not enough I'll gladly accept your help.

@hirasso
Copy link
Contributor Author

hirasso commented Dec 10, 2022

I just tried merging upstream/trunk to my local branch (accepting all incoming changes). When trying to commit the merge, I get an alert and it doesn't continue:

image

Here is the result of clicking on "Show Command Output" (sorry, a lot of text):

> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
Prettier formatting staged file: projects/js-packages/components/components/action-popover/index.tsx
Prettier formatting staged file: projects/js-packages/components/components/action-popover/stories/index.jsx
Prettier formatting staged file: projects/js-packages/components/components/action-popover/types.ts
Prettier formatting staged file: projects/js-packages/components/package.json
Prettier formatting staged file: projects/js-packages/connection/package.json
Prettier formatting staged file: projects/js-packages/partner-coupon/package.json
Prettier formatting staged file: projects/js-packages/publicize-components/package.json
Prettier formatting staged file: projects/js-packages/publicize-components/src/components/form/index.js
Prettier formatting staged file: projects/js-packages/publicize-components/src/components/media-section/index.js
Prettier formatting staged file: projects/js-packages/publicize-components/src/components/panel/index.jsx
Prettier formatting staged file: projects/js-packages/publicize-components/src/hooks/use-media-restrictions/index.js
Prettier formatting staged file: projects/js-packages/publicize-components/src/hooks/use-media-restrictions/test/index.test.js
Prettier formatting staged file: projects/js-packages/publicize-components/src/hooks/use-publicize-config/index.js
Prettier formatting staged file: projects/js-packages/publicize-components/src/hooks/use-social-media-connections/index.js
Prettier formatting staged file: projects/js-packages/shared-extension-utils/package.json
Prettier formatting staged file: projects/packages/action-bar/package.json
Prettier formatting staged file: projects/packages/config/composer.json
Prettier formatting staged file: projects/packages/google-fonts-provider/composer.json
Prettier formatting staged file: projects/packages/google-fonts-provider/package.json
Prettier formatting staged file: projects/packages/my-jetpack/package.json
Prettier formatting staged file: projects/packages/publicize/package.json
Prettier formatting staged file: projects/packages/search/package.json
Prettier formatting staged file: projects/packages/stats-admin/package.json
Prettier formatting staged file: projects/packages/transport-helper/package.json
Prettier formatting staged file: projects/packages/videopress/composer.json
Prettier formatting staged file: projects/packages/videopress/package.json
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/admin-page/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/admin-page/libraries.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/admin-page/types.ts
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/edit-video-details/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/pagination/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/pricing-section/stories/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/publish-first-video-popover/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/publish-first-video-popover/types.ts
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/video-card/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/video-filter/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/video-filter/types.ts
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/video-row/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/components/video-thumbnail/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/admin/hooks/use-query-string-pages/index.ts
Prettier formatting staged file: projects/packages/videopress/src/client/admin/hooks/use-search-params/index.ts
Prettier formatting staged file: projects/packages/videopress/src/client/admin/hooks/use-videos/index.js
Prettier formatting staged file: projects/packages/videopress/src/client/admin/types/index.ts
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/blocks/video/block.json
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/blocks/video/components/privacy-and-rating-panel/index.tsx
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/blocks/video/components/videopress-uploader/index.js
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/blocks/video/save.js
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/blocks/video/types.ts
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/extend/core-embed/index.js
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/hooks/use-video-data-update/index.ts
Prettier formatting staged file: projects/packages/videopress/src/client/block-editor/hooks/use-video-data/index.ts
Prettier formatting staged file: projects/packages/videopress/src/client/lib/url/index.ts
Prettier formatting staged file: projects/packages/videopress/src/client/lib/video-tracks/index.ts
Prettier formatting staged file: projects/packages/videopress/src/client/state/actions.js
Prettier formatting staged file: projects/packages/videopress/src/client/state/constants.js
Prettier formatting staged file: projects/packages/videopress/src/client/state/reducers.js
Prettier formatting staged file: projects/packages/videopress/src/client/state/resolvers.js
Prettier formatting staged file: projects/packages/videopress/src/client/state/selectors.js
Prettier formatting staged file: projects/packages/videopress/src/client/state/utils/map-videos.ts
Prettier formatting staged file: projects/packages/videopress/src/client/types.ts
Prettier formatting staged file: projects/packages/waf/composer.json
Prettier formatting staged file: projects/packages/wordads/package.json
Prettier formatting staged file: projects/plugins/jetpack-mu-wpcom/composer.json
Prettier formatting staged file: projects/plugins/jetpack-mu-wpcom/package.json
Prettier formatting staged file: projects/plugins/jetpack/composer.json
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/contact-form/child-blocks.js
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/contact-form/components/jetpack-email-connection-settings.js
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/contact-form/components/jetpack-manage-responses-settings.js
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/contact-form/edit.js
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/contact-form/index.js
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/subscriptions/api.js
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/videopress/editor.js
Prettier formatting staged file: projects/plugins/jetpack/extensions/blocks/videopress/utils.js
Prettier formatting staged file: projects/plugins/jetpack/package.json
Prettier formatting staged file: projects/plugins/protect/composer.json
Prettier formatting staged file: projects/plugins/protect/package.json
Prettier formatting staged file: projects/plugins/protect/src/js/api.js
Prettier formatting staged file: projects/plugins/protect/src/js/components/admin-page/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/admin-page/use-registration-watcher.js
Prettier formatting staged file: projects/plugins/protect/src/js/components/firewall-footer/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/firewall-footer/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/firewall-header/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/firewall-header/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/firewall-page/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/form-toggle/compact.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/form-toggle/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/form-toggle/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/interstitial-page/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/interstitial-page/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/interstitial-page/stories/mock.js
Prettier formatting staged file: projects/plugins/protect/src/js/components/modal/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/notice/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/notice/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/pricing-table/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/pricing-table/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/scan-footer/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/scan-footer/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/scan-page/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/scan-page/use-credentials.js
Prettier formatting staged file: projects/plugins/protect/src/js/components/scan-page/use-status-polling.js
Prettier formatting staged file: projects/plugins/protect/src/js/components/seventy-five-layout/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/standalone-mode-modal/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/tabs/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/tabs/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/textarea/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/textarea/stories/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/components/threats-list/paid-list.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/constants.js
Prettier formatting staged file: projects/plugins/protect/src/js/hooks/use-waf-data/index.jsx
Prettier formatting staged file: projects/plugins/protect/src/js/index.js
Prettier formatting staged file: projects/plugins/protect/src/js/state/actions.js
Prettier formatting staged file: projects/plugins/protect/src/js/state/reducers.js
Prettier formatting staged file: projects/plugins/protect/src/js/state/selectors.js
Prettier formatting staged file: projects/plugins/starter-plugin/composer.json
Prettier formatting staged file: projects/plugins/starter-plugin/jest.config.js
Prettier formatting staged file: projects/plugins/starter-plugin/jest.setup.js
Prettier formatting staged file: projects/plugins/starter-plugin/package.json
Prettier formatting staged file: projects/plugins/starter-plugin/src/js/components/admin-page/test/index.test.js
Prettier formatting staged file: projects/plugins/super-cache/.eslintrc.cjs
Prettier formatting staged file: projects/plugins/super-cache/composer.json
Prettier formatting staged file: projects/plugins/super-cache/js/admin.js
Prettier formatting staged file: projects/plugins/super-cache/package.json
Prettier formatting staged file: tools/cli/commands/release.js
Prettier formatting staged file: tools/e2e-commons/env/prerequisites.js
projects/js-packages/components/components/action-popover/index.tsx 249ms
projects/js-packages/components/components/action-popover/stories/index.jsx 93ms
projects/js-packages/components/components/action-popover/types.ts 20ms
projects/js-packages/components/package.json 8ms
projects/js-packages/connection/package.json 5ms
projects/js-packages/partner-coupon/package.json 5ms
projects/js-packages/publicize-components/package.json 8ms
projects/js-packages/publicize-components/src/components/form/index.js 87ms
projects/js-packages/publicize-components/src/components/media-section/index.js 69ms
projects/js-packages/publicize-components/src/components/panel/index.jsx 23ms
projects/js-packages/publicize-components/src/hooks/use-media-restrictions/index.js 28ms
projects/js-packages/publicize-components/src/hooks/use-media-restrictions/test/index.test.js 20ms
projects/js-packages/publicize-components/src/hooks/use-publicize-config/index.js 20ms
projects/js-packages/publicize-components/src/hooks/use-social-media-connections/index.js 7ms
projects/js-packages/shared-extension-utils/package.json 3ms
projects/packages/action-bar/package.json 3ms
projects/packages/config/composer.json 5ms
projects/packages/google-fonts-provider/composer.json 4ms
projects/packages/google-fonts-provider/package.json 3ms
projects/packages/my-jetpack/package.json 3ms
projects/packages/publicize/package.json 6ms
projects/packages/search/package.json 6ms
projects/packages/stats-admin/package.json 6ms
projects/packages/transport-helper/package.json 5ms
projects/packages/videopress/composer.json 8ms
projects/packages/videopress/package.json 7ms
projects/packages/videopress/src/client/admin/components/admin-page/index.tsx 84ms
projects/packages/videopress/src/client/admin/components/admin-page/libraries.tsx 60ms
projects/packages/videopress/src/client/admin/components/admin-page/types.ts 14ms
projects/packages/videopress/src/client/admin/components/edit-video-details/index.tsx 66ms
projects/packages/videopress/src/client/admin/components/pagination/index.tsx 60ms
projects/packages/videopress/src/client/admin/components/pricing-section/stories/index.tsx 25ms
projects/packages/videopress/src/client/admin/components/publish-first-video-popover/index.tsx 26ms
projects/packages/videopress/src/client/admin/components/publish-first-video-popover/types.ts 7ms
projects/packages/videopress/src/client/admin/components/video-card/index.tsx 22ms
projects/packages/videopress/src/client/admin/components/video-filter/index.tsx 46ms
projects/packages/videopress/src/client/admin/components/video-filter/types.ts 14ms
projects/packages/videopress/src/client/admin/components/video-row/index.tsx 49ms
projects/packages/videopress/src/client/admin/components/video-thumbnail/index.tsx 33ms
projects/packages/videopress/src/client/admin/hooks/use-query-string-pages/index.ts 8ms
projects/packages/videopress/src/client/admin/hooks/use-search-params/index.ts 2ms
projects/packages/videopress/src/client/admin/hooks/use-videos/index.js 27ms
projects/packages/videopress/src/client/admin/types/index.ts 23ms
projects/packages/videopress/src/client/block-editor/blocks/video/block.json 10ms
projects/packages/videopress/src/client/block-editor/blocks/video/components/privacy-and-rating-panel/index.tsx 14ms
projects/packages/videopress/src/client/block-editor/blocks/video/components/videopress-uploader/index.js 38ms
projects/packages/videopress/src/client/block-editor/blocks/video/save.js 16ms
projects/packages/videopress/src/client/block-editor/blocks/video/types.ts 10ms
projects/packages/videopress/src/client/block-editor/extend/core-embed/index.js 7ms
projects/packages/videopress/src/client/block-editor/hooks/use-video-data-update/index.ts 26ms
projects/packages/videopress/src/client/block-editor/hooks/use-video-data/index.ts 17ms
projects/packages/videopress/src/client/lib/url/index.ts 12ms
projects/packages/videopress/src/client/lib/video-tracks/index.ts 25ms
projects/packages/videopress/src/client/state/actions.js 41ms
projects/packages/videopress/src/client/state/constants.js 13ms
projects/packages/videopress/src/client/state/reducers.js 35ms
projects/packages/videopress/src/client/state/resolvers.js 41ms
projects/packages/videopress/src/client/state/selectors.js 10ms
projects/packages/videopress/src/client/state/utils/map-videos.ts 15ms
projects/packages/videopress/src/client/types.ts 14ms
projects/packages/waf/composer.json 5ms
projects/packages/wordads/package.json 2ms
projects/plugins/jetpack-mu-wpcom/composer.json 2ms
projects/plugins/jetpack-mu-wpcom/package.json 1ms
projects/plugins/jetpack/composer.json 3ms
projects/plugins/jetpack/extensions/blocks/contact-form/child-blocks.js 38ms
projects/plugins/jetpack/extensions/blocks/contact-form/components/jetpack-email-connection-settings.js 16ms
projects/plugins/jetpack/extensions/blocks/contact-form/components/jetpack-manage-responses-settings.js 8ms
projects/plugins/jetpack/extensions/blocks/contact-form/edit.js 21ms
projects/plugins/jetpack/extensions/blocks/contact-form/index.js 6ms
projects/plugins/jetpack/extensions/blocks/subscriptions/api.js 3ms
projects/plugins/jetpack/extensions/blocks/videopress/editor.js 24ms
projects/plugins/jetpack/extensions/blocks/videopress/utils.js 8ms
projects/plugins/jetpack/package.json 5ms
projects/plugins/protect/composer.json 4ms
projects/plugins/protect/package.json 2ms
projects/plugins/protect/src/js/api.js 5ms
projects/plugins/protect/src/js/components/admin-page/index.jsx 8ms
projects/plugins/protect/src/js/components/admin-page/use-registration-watcher.js 5ms
projects/plugins/protect/src/js/components/firewall-footer/index.jsx 5ms
projects/plugins/protect/src/js/components/firewall-footer/stories/index.jsx 4ms
projects/plugins/protect/src/js/components/firewall-header/index.jsx 36ms
projects/plugins/protect/src/js/components/firewall-header/stories/index.jsx 6ms
projects/plugins/protect/src/js/components/firewall-page/index.jsx 27ms
projects/plugins/protect/src/js/components/form-toggle/compact.jsx 5ms
projects/plugins/protect/src/js/components/form-toggle/index.jsx 12ms
projects/plugins/protect/src/js/components/form-toggle/stories/index.jsx 6ms
projects/plugins/protect/src/js/components/interstitial-page/index.jsx 9ms
projects/plugins/protect/src/js/components/interstitial-page/stories/index.jsx 8ms
projects/plugins/protect/src/js/components/interstitial-page/stories/mock.js 34ms
projects/plugins/protect/src/js/components/modal/index.jsx 10ms
projects/plugins/protect/src/js/components/notice/index.jsx 6ms
projects/plugins/protect/src/js/components/notice/stories/index.jsx 4ms
projects/plugins/protect/src/js/components/pricing-table/index.jsx 16ms
projects/plugins/protect/src/js/components/pricing-table/stories/index.jsx 5ms
projects/plugins/protect/src/js/components/scan-footer/index.jsx 10ms
projects/plugins/protect/src/js/components/scan-footer/stories/index.jsx 6ms
projects/plugins/protect/src/js/components/scan-page/index.jsx 16ms
projects/plugins/protect/src/js/components/scan-page/use-credentials.js 6ms
projects/plugins/protect/src/js/components/scan-page/use-status-polling.js 6ms
projects/plugins/protect/src/js/components/seventy-five-layout/index.jsx 3ms
projects/plugins/protect/src/js/components/standalone-mode-modal/index.jsx 2ms
projects/plugins/protect/src/js/components/tabs/index.jsx 4ms
projects/plugins/protect/src/js/components/tabs/stories/index.jsx 5ms
projects/plugins/protect/src/js/components/textarea/index.jsx 8ms
projects/plugins/protect/src/js/components/textarea/stories/index.jsx 7ms
projects/plugins/protect/src/js/components/threats-list/paid-list.jsx 22ms
projects/plugins/protect/src/js/constants.js 5ms
projects/plugins/protect/src/js/hooks/use-waf-data/index.jsx 11ms
projects/plugins/protect/src/js/index.js 8ms
projects/plugins/protect/src/js/state/actions.js 34ms
projects/plugins/protect/src/js/state/reducers.js 15ms
projects/plugins/protect/src/js/state/selectors.js 3ms
projects/plugins/starter-plugin/composer.json 2ms
projects/plugins/starter-plugin/jest.config.js 1ms
projects/plugins/starter-plugin/jest.setup.js 1ms
projects/plugins/starter-plugin/package.json 1ms
projects/plugins/starter-plugin/src/js/components/admin-page/test/index.test.js 5ms
projects/plugins/super-cache/.eslintrc.cjs 4ms
projects/plugins/super-cache/composer.json 3ms
projects/plugins/super-cache/js/admin.js 7ms
projects/plugins/super-cache/package.json 1ms
tools/cli/commands/release.js 33ms
tools/e2e-commons/env/prerequisites.js 33ms

> @automattic/Jetpack_Monorepo@ lint-file /Users/rah/Sites/herzogdemeuron/wwwroot/packages/jetpack-monorepo
> eslint --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.svelte "--max-warnings=0" "--fix" "projects/js-packages/components/components/action-popover/index.tsx" "projects/js-packages/components/components/action-popover/stories/index.jsx" "projects/js-packages/components/components/action-popover/types.ts" "projects/js-packages/publicize-components/src/components/form/index.js" "projects/js-packages/publicize-components/src/components/media-section/index.js" "projects/js-packages/publicize-components/src/components/panel/index.jsx" "projects/js-packages/publicize-components/src/hooks/use-media-restrictions/index.js" "projects/js-packages/publicize-components/src/hooks/use-media-restrictions/test/index.test.js" "projects/js-packages/publicize-components/src/hooks/use-publicize-config/index.js" "projects/js-packages/publicize-components/src/hooks/use-social-media-connections/index.js" "projects/packages/videopress/src/client/admin/components/admin-page/index.tsx" "projects/packages/videopress/src/client/admin/components/admin-page/libraries.tsx" "projects/packages/videopress/src/client/admin/components/admin-page/types.ts" "projects/packages/videopress/src/client/admin/components/edit-video-details/index.tsx" "projects/packages/videopress/src/client/admin/components/pagination/index.tsx" "projects/packages/videopress/src/client/admin/components/pricing-section/stories/index.tsx" "projects/packages/videopress/src/client/admin/components/publish-first-video-popover/index.tsx" "projects/packages/videopress/src/client/admin/components/publish-first-video-popover/types.ts" "projects/packages/videopress/src/client/admin/components/video-card/index.tsx" "projects/packages/videopress/src/client/admin/components/video-filter/index.tsx" "projects/packages/videopress/src/client/admin/components/video-filter/types.ts" "projects/packages/videopress/src/client/admin/components/video-row/index.tsx" "projects/packages/videopress/src/client/admin/components/video-thumbnail/index.tsx" "projects/packages/videopress/src/client/admin/hooks/use-query-string-pages/index.ts" "projects/packages/videopress/src/client/admin/hooks/use-search-params/index.ts" "projects/packages/videopress/src/client/admin/hooks/use-videos/index.js" "projects/packages/videopress/src/client/admin/types/index.ts" "projects/packages/videopress/src/client/block-editor/blocks/video/components/privacy-and-rating-panel/index.tsx" "projects/packages/videopress/src/client/block-editor/blocks/video/components/videopress-uploader/index.js" "projects/packages/videopress/src/client/block-editor/blocks/video/save.js" "projects/packages/videopress/src/client/block-editor/blocks/video/types.ts" "projects/packages/videopress/src/client/block-editor/extend/core-embed/index.js" "projects/packages/videopress/src/client/block-editor/hooks/use-video-data-update/index.ts" "projects/packages/videopress/src/client/block-editor/hooks/use-video-data/index.ts" "projects/packages/videopress/src/client/lib/url/index.ts" "projects/packages/videopress/src/client/lib/video-tracks/index.ts" "projects/packages/videopress/src/client/state/actions.js" "projects/packages/videopress/src/client/state/constants.js" "projects/packages/videopress/src/client/state/reducers.js" "projects/packages/videopress/src/client/state/resolvers.js" "projects/packages/videopress/src/client/state/selectors.js" "projects/packages/videopress/src/client/state/utils/map-videos.ts" "projects/packages/videopress/src/client/types.ts" "projects/plugins/jetpack/extensions/blocks/contact-form/child-blocks.js" "projects/plugins/jetpack/extensions/blocks/contact-form/components/jetpack-email-connection-settings.js" "projects/plugins/jetpack/extensions/blocks/contact-form/components/jetpack-manage-responses-settings.js" "projects/plugins/jetpack/extensions/blocks/contact-form/edit.js" "projects/plugins/jetpack/extensions/blocks/contact-form/index.js" "projects/plugins/jetpack/extensions/blocks/subscriptions/api.js" "projects/plugins/jetpack/extensions/blocks/videopress/editor.js" "projects/plugins/protect/src/js/api.js" "projects/plugins/protect/src/js/components/admin-page/index.jsx" "projects/plugins/protect/src/js/components/admin-page/use-registration-watcher.js" "projects/plugins/protect/src/js/components/firewall-footer/index.jsx" "projects/plugins/protect/src/js/components/firewall-footer/stories/index.jsx" "projects/plugins/protect/src/js/components/firewall-header/index.jsx" "projects/plugins/protect/src/js/components/firewall-header/stories/index.jsx" "projects/plugins/protect/src/js/components/firewall-page/index.jsx" "projects/plugins/protect/src/js/components/form-toggle/compact.jsx" "projects/plugins/protect/src/js/components/form-toggle/index.jsx" "projects/plugins/protect/src/js/components/form-toggle/stories/index.jsx" "projects/plugins/protect/src/js/components/interstitial-page/index.jsx" "projects/plugins/protect/src/js/components/interstitial-page/stories/index.jsx" "projects/plugins/protect/src/js/components/interstitial-page/stories/mock.js" "projects/plugins/protect/src/js/components/modal/index.jsx" "projects/plugins/protect/src/js/components/notice/index.jsx" "projects/plugins/protect/src/js/components/notice/stories/index.jsx" "projects/plugins/protect/src/js/components/pricing-table/index.jsx" "projects/plugins/protect/src/js/components/pricing-table/stories/index.jsx" "projects/plugins/protect/src/js/components/scan-footer/index.jsx" "projects/plugins/protect/src/js/components/scan-footer/stories/index.jsx" "projects/plugins/protect/src/js/components/scan-page/index.jsx" "projects/plugins/protect/src/js/components/scan-page/use-credentials.js" "projects/plugins/protect/src/js/components/scan-page/use-status-polling.js" "projects/plugins/protect/src/js/components/seventy-five-layout/index.jsx" "projects/plugins/protect/src/js/components/standalone-mode-modal/index.jsx" "projects/plugins/protect/src/js/components/tabs/index.jsx" "projects/plugins/protect/src/js/components/tabs/stories/index.jsx" "projects/plugins/protect/src/js/components/textarea/index.jsx" "projects/plugins/protect/src/js/components/textarea/stories/index.jsx" "projects/plugins/protect/src/js/components/threats-list/paid-list.jsx" "projects/plugins/protect/src/js/constants.js" "projects/plugins/protect/src/js/hooks/use-waf-data/index.jsx" "projects/plugins/protect/src/js/index.js" "projects/plugins/protect/src/js/state/actions.js" "projects/plugins/protect/src/js/state/reducers.js" "projects/plugins/protect/src/js/state/selectors.js" "projects/plugins/starter-plugin/jest.config.js" "projects/plugins/starter-plugin/jest.setup.js" "projects/plugins/starter-plugin/src/js/components/admin-page/test/index.test.js" "projects/plugins/super-cache/.eslintrc.cjs" "projects/plugins/super-cache/js/admin.js" "tools/cli/commands/release.js" "tools/e2e-commons/env/prerequisites.js"


> @automattic/Jetpack_Monorepo@ lint-changed /Users/rah/Sites/herzogdemeuron/wwwroot/packages/jetpack-monorepo
> eslint-changed --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.svelte --git "projects/plugins/jetpack/extensions/blocks/videopress/utils.js"

> printf '\e[30;43m`composer php:lint` now lints. If you want to run phpcs, use `composer phpcs:lint`.\e[0m\n' '--files' 'projects/packages/backup/src/class-package-version.php' 'projects/packages/config/src/class-config.php' 'projects/packages/google-fonts-provider/src/class-google-fonts-provider.php' 'projects/packages/google-fonts-provider/tests/php/test-google-fonts-provider.php' 'projects/packages/my-jetpack/src/class-initializer.php' 'projects/packages/post-list/src/class-post-list.php' 'projects/packages/publicize/src/class-share-limits.php' 'projects/packages/search/src/class-cli.php' 'projects/packages/search/src/class-package.php' 'projects/packages/stats-admin/src/class-main.php' 'projects/packages/sync/src/class-defaults.php' 'projects/packages/sync/src/class-package-version.php' 'projects/packages/transport-helper/src/class-package-version.php' 'projects/packages/videopress/src/class-admin-ui.php' 'projects/packages/videopress/src/class-block-editor-content.php' 'projects/packages/videopress/src/class-data.php' 'projects/packages/videopress/src/class-initializer.php' 'projects/packages/videopress/src/class-package-version.php' 'projects/packages/videopress/src/class-wpcom-rest-api-v2-attachment-videopress-data.php' 'projects/packages/videopress/src/utility-functions.php' 'projects/packages/waf/src/class-rest-controller.php' 'projects/packages/waf/src/class-waf-initializer.php' 'projects/packages/waf/src/class-waf-runner.php' 'projects/packages/waf/src/class-waf-transforms.php' 'projects/packages/wordads/src/class-package.php' 'projects/plugins/boost/app/class-jetpack-boost.php' 'projects/plugins/boost/app/lib/class-site-urls.php' 'projects/plugins/boost/app/rest-api/endpoints/List_Site_Urls.php' 'projects/plugins/jetpack-mu-wpcom/jetpack-mu-wpcom.php' 'projects/plugins/jetpack-mu-wpcom/src/example.php' 'projects/plugins/jetpack-mu-wpcom/tests/php/bootstrap.php' 'projects/plugins/jetpack/_inc/blogging-prompts.php' 'projects/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-redux-state-helper.php' 'projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php' 'projects/plugins/jetpack/_inc/lib/class.media-extractor.php' 'projects/plugins/jetpack/_inc/lib/components.php' 'projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/subscribers.php' 'projects/plugins/jetpack/class.jetpack.php' 'projects/plugins/jetpack/extensions/blocks/blogging-prompts/blogging-prompts.php' 'projects/plugins/jetpack/extensions/blocks/blogging-prompts/settings.php' 'projects/plugins/jetpack/extensions/blocks/podcast-player/podcast-player.php' 'projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php' 'projects/plugins/jetpack/extensions/blocks/videopress/videopress.php' 'projects/plugins/jetpack/jetpack.php' 'projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php' 'projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-v1-4-endpoint.php' 'projects/plugins/jetpack/modules/calypsoify/class-jetpack-calypsoify.php' 'projects/plugins/jetpack/modules/carousel/jetpack-carousel.php' 'projects/plugins/jetpack/modules/comments/comments.php' 'projects/plugins/jetpack/modules/masterbar/admin-menu/class-jetpack-admin-menu.php' 'projects/plugins/jetpack/modules/sharedaddy/sharing-sources.php' 'projects/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php' 'projects/plugins/jetpack/modules/shortcodes/dailymotion.php' 'projects/plugins/jetpack/modules/shortcodes/getty.php' 'projects/plugins/jetpack/modules/shortcodes/googleapps.php' 'projects/plugins/jetpack/modules/shortcodes/kickstarter.php' 'projects/plugins/jetpack/modules/shortcodes/soundcloud.php' 'projects/plugins/jetpack/modules/shortcodes/vimeo.php' 'projects/plugins/jetpack/modules/shortcodes/youtube.php' 'projects/plugins/jetpack/modules/simple-payments/simple-payments.php' 'projects/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php' 'projects/plugins/jetpack/modules/sitemaps/sitemap-builder.php' 'projects/plugins/jetpack/modules/subscriptions/views.php' 'projects/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php' 'projects/plugins/jetpack/modules/widgets/flickr.php' 'projects/plugins/jetpack/modules/widgets/migrate-to-core/gallery-widget.php' 'projects/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php' 'projects/plugins/jetpack/sal/class.json-api-post-base.php' 'projects/plugins/jetpack/tests/php/bootstrap.php' 'projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php' 'projects/plugins/jetpack/tests/php/test_class.jetpack_photon.php' 'projects/plugins/protect/jetpack-protect.php' 'projects/plugins/protect/src/class-jetpack-protect.php' 'projects/plugins/social/jetpack-social.php' 'projects/plugins/social/src/class-jetpack-social.php' 'projects/plugins/starter-plugin/tests/php/bootstrap.php' 'projects/plugins/starter-plugin/tests/php/test-class-jetpack-starter-plugin.php' 'projects/plugins/super-cache/wp-cache-base.php' 'projects/plugins/super-cache/wp-cache-phase2.php' 'projects/plugins/super-cache/wp-cache.php' 'tools/check-changelogger-use.php' 'tools/docker/mu-plugins/avoid-plugin-deletion.php' '--ansi'
�[30;43m`composer php:lint` now lints. If you want to run phpcs, use `composer phpcs:lint`.�[0m
> tools/parallel-lint.sh '--files' 'projects/packages/backup/src/class-package-version.php' 'projects/packages/config/src/class-config.php' 'projects/packages/google-fonts-provider/src/class-google-fonts-provider.php' 'projects/packages/google-fonts-provider/tests/php/test-google-fonts-provider.php' 'projects/packages/my-jetpack/src/class-initializer.php' 'projects/packages/post-list/src/class-post-list.php' 'projects/packages/publicize/src/class-share-limits.php' 'projects/packages/search/src/class-cli.php' 'projects/packages/search/src/class-package.php' 'projects/packages/stats-admin/src/class-main.php' 'projects/packages/sync/src/class-defaults.php' 'projects/packages/sync/src/class-package-version.php' 'projects/packages/transport-helper/src/class-package-version.php' 'projects/packages/videopress/src/class-admin-ui.php' 'projects/packages/videopress/src/class-block-editor-content.php' 'projects/packages/videopress/src/class-data.php' 'projects/packages/videopress/src/class-initializer.php' 'projects/packages/videopress/src/class-package-version.php' 'projects/packages/videopress/src/class-wpcom-rest-api-v2-attachment-videopress-data.php' 'projects/packages/videopress/src/utility-functions.php' 'projects/packages/waf/src/class-rest-controller.php' 'projects/packages/waf/src/class-waf-initializer.php' 'projects/packages/waf/src/class-waf-runner.php' 'projects/packages/waf/src/class-waf-transforms.php' 'projects/packages/wordads/src/class-package.php' 'projects/plugins/boost/app/class-jetpack-boost.php' 'projects/plugins/boost/app/lib/class-site-urls.php' 'projects/plugins/boost/app/rest-api/endpoints/List_Site_Urls.php' 'projects/plugins/jetpack-mu-wpcom/jetpack-mu-wpcom.php' 'projects/plugins/jetpack-mu-wpcom/src/example.php' 'projects/plugins/jetpack-mu-wpcom/tests/php/bootstrap.php' 'projects/plugins/jetpack/_inc/blogging-prompts.php' 'projects/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-redux-state-helper.php' 'projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php' 'projects/plugins/jetpack/_inc/lib/class.media-extractor.php' 'projects/plugins/jetpack/_inc/lib/components.php' 'projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/subscribers.php' 'projects/plugins/jetpack/class.jetpack.php' 'projects/plugins/jetpack/extensions/blocks/blogging-prompts/blogging-prompts.php' 'projects/plugins/jetpack/extensions/blocks/blogging-prompts/settings.php' 'projects/plugins/jetpack/extensions/blocks/podcast-player/podcast-player.php' 'projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php' 'projects/plugins/jetpack/extensions/blocks/videopress/videopress.php' 'projects/plugins/jetpack/jetpack.php' 'projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php' 'projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-v1-4-endpoint.php' 'projects/plugins/jetpack/modules/calypsoify/class-jetpack-calypsoify.php' 'projects/plugins/jetpack/modules/carousel/jetpack-carousel.php' 'projects/plugins/jetpack/modules/comments/comments.php' 'projects/plugins/jetpack/modules/masterbar/admin-menu/class-jetpack-admin-menu.php' 'projects/plugins/jetpack/modules/sharedaddy/sharing-sources.php' 'projects/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php' 'projects/plugins/jetpack/modules/shortcodes/dailymotion.php' 'projects/plugins/jetpack/modules/shortcodes/getty.php' 'projects/plugins/jetpack/modules/shortcodes/googleapps.php' 'projects/plugins/jetpack/modules/shortcodes/kickstarter.php' 'projects/plugins/jetpack/modules/shortcodes/soundcloud.php' 'projects/plugins/jetpack/modules/shortcodes/vimeo.php' 'projects/plugins/jetpack/modules/shortcodes/youtube.php' 'projects/plugins/jetpack/modules/simple-payments/simple-payments.php' 'projects/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php' 'projects/plugins/jetpack/modules/sitemaps/sitemap-builder.php' 'projects/plugins/jetpack/modules/subscriptions/views.php' 'projects/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php' 'projects/plugins/jetpack/modules/widgets/flickr.php' 'projects/plugins/jetpack/modules/widgets/migrate-to-core/gallery-widget.php' 'projects/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php' 'projects/plugins/jetpack/sal/class.json-api-post-base.php' 'projects/plugins/jetpack/tests/php/bootstrap.php' 'projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php' 'projects/plugins/jetpack/tests/php/test_class.jetpack_photon.php' 'projects/plugins/protect/jetpack-protect.php' 'projects/plugins/protect/src/class-jetpack-protect.php' 'projects/plugins/social/jetpack-social.php' 'projects/plugins/social/src/class-jetpack-social.php' 'projects/plugins/starter-plugin/tests/php/bootstrap.php' 'projects/plugins/starter-plugin/tests/php/test-class-jetpack-starter-plugin.php' 'projects/plugins/super-cache/wp-cache-base.php' 'projects/plugins/super-cache/wp-cache-phase2.php' 'projects/plugins/super-cache/wp-cache.php' 'tools/check-changelogger-use.php' 'tools/docker/mu-plugins/avoid-plugin-deletion.php' '--ansi'
Invalid option --ansi

Options:
    -p <php>                Specify PHP-CGI executable to run (default: 'php').
    -s, --short             Set short_open_tag to On (default: Off).
    -a, --asp               Set asp_tags to On (default: Off).
    -e <ext>                Check only files with selected extensions separated by comma.
                            (default: php,php3,php4,php5,phtml,phpt)
    -j <num>                Run <num> jobs in parallel (default: 10).
    --exclude               Exclude a file or directory. If you want exclude multiple items,
                            use multiple exclude parameters.
    --colors                Enable colors in console output.
                            (disables auto detection of color support)
    --no-colors             Disable colors in console output.
    --no-progress           Disable progress in console output.
    --checkstyle            Output results as Checkstyle XML.
    --json                  Output results as JSON string
                            (requires PHP 5.4).
    --gitlab                Output results for the GitLab Code Quality Widget
                            (requires PHP 5.4).
    --blame                 Try to show git blame for row with error.
    --git <git>             Path to Git executable to show blame message (default: 'git').
    --stdin                 Load files and folder to test from standard input.
    --ignore-fails          Ignore failed tests.
    --show-deprecated       Show deprecations (default: Off).
    --syntax-error-callback File with syntax error callback for ability to modify error
    -h, --help              Print this help.
    -V, --version           Display the application version
Script tools/parallel-lint.sh handling the php:lint event returned with error code 254
COMMIT ABORTED: PHP found linting/syntax errors!
If you are aware of them and it is OK, repeat the commit command with --no-verify to avoid this check.
But please don't. Code is poetry.


husky - pre-commit hook exited with code 1 (error)

@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Pri] Low and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Dec 12, 2022
@thingalon
Copy link
Member

Hi @hirasso! Thanks for contributing to Super Cache. I understand that contributing to the Jetpack monorepo can be intimidating :) I appreciate that you've taken the time to get involved.

I want to check something about the change you've made here. It looks like you've added the "Accept-Ranges" header to the .htaccess file Super Cache generates inside its cache folder, affecting the HTML pages it has cached there.

I don't believe this will affect other resources (e.g.: fonts, images, etc) loaded statically out of your wp-content directory, so I worry that this won't quite do what you're after.

Can you tell me a little bit more about your site? Are you using this to preload other documents (I believe browser support for this is sketchy at the moment), or are you aiming to preload static resources such as fonts and images used by your theme?

@thingalon thingalon added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Dec 13, 2022
@hirasso
Copy link
Contributor Author

hirasso commented Dec 13, 2022

First of all, thanks a lot @jeherve for your help with preparing this PR.

@thingalon Thank you for your friendly message!

I'll try to explain my use case a bit more. I am using quicklink on my site to dynamically prefetch other pages that I'm quite sure the visitor will need.

Quicklink will inject <link rel="prefetch"> tags into the header of my site. Now as stated in the MDN article I linked to above:

If a prefetched document is partially downloaded, then the partial document will still be stored in the cache provided the server sent an "Accept-Ranges: bytes" response header.

...and can be reused if the request restarts, if I read correctly.

While quicklink does quite aggressive prefetching, there are other libraries like https://instant.page/, that prefetch links (inject a link[rel="prefetch"] into the documents <head>) as soon as the user hovers a link (or touches his phone). The Accept-Ranges: bytes header could really provide some perceived performance improvements here, I think:

  1. The user hovers a link, a prefetch link is being injected
  2. The browser starts prefetching the linked page
  3. The user clicks the link before the full page was prefetched
  4. The browser stops all prefetch requests and loads the clicked page
  5. If the page provided the Accept-Ranges: bytes header, the browser can reuse the partially loaded page. Otherwise, it has to re-fetch the whole page

Another snippet from the MDN article:

This header is typically generated by webservers when serving up static content.

The html files in the cache folder are static files after all, right? :)

Looking forward to hear your thoughts.

@thingalon
Copy link
Member

Thanks for the extra context @hirasso. I have some good news for you: we don't need to modify Super Cache to accomplish your goals.

Inside wp-content/cache/.htaccess, there is a line:

# END supercache

This marks the last line that Super Cache will modify in that htaccess file, so you can add custom code after that - and Super Cache will not overwrite it.

So, if you add the following to your wp-content/cache/.htaccess file below the # END supercache line:

<IfModule mod_headers.c>
  Header set Accept-Ranges 'bytes'
</IfModule>

... it should accomplish your goals. Just make sure that you have mod_headers enabled in your Apache setup, so that it can respect those lines an add the Accept-Ranges header for you - and you should be all set.

I don't want to add extra lines to WP Super Cache's default "expert" mode config files to support 3rd party plugins - unless we're absolutely sure it will be of benefit to the majority of our user-base. So I'm afraid I'm going to close this PR without merging it.

But I hope the way I've identified for you can help you set your site up the way you want it! 😄

@thingalon thingalon closed this Dec 15, 2022
@github-actions github-actions bot removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Dec 15, 2022
@hirasso
Copy link
Contributor Author

hirasso commented Dec 15, 2022

Ok @thingalon , I'm sure you have good reasons not to accept every feature request to a plugin like super cache, that is so widely being used.

Thank you for your hint towards the possibility to add custom stuff to the .htaccess manually!

Since I am planning to have this feature available on more than one site and I'm sure that I won't remember to put my custom directives in the .htaccess every time I (de-)activate wp-super-cache, not to speak of different environments (local, staging, production), I have written this function to do it automatically for me, every time I clear the cache:

/**
 * Modifies the .htaccess in the WP Super Cache 
 * directory `wp-content/cache/.htaccess`
 *
 * @return void
 */
function modify_wpsc_cache_dir_htaccess() {
    // Bail early if the .htaccess doesn't exist
    $htaccess_path = WP_CONTENT_DIR . '/cache/.htaccess';
    if (!file_exists($htaccess_path)) return;

    // Make sure `insert_with_markers` is available in WP_CLI
    if (!function_exists('insert_with_markers')) {
        require_once(ABSPATH . 'wp-admin/includes/misc.php');
    }

    // Our custom directives
    $custom_directives = [
        "<IfModule mod_headers.c>",
        "Header set Accept-Ranges 'bytes'",
        "</IfModule>"
    ];

    // Update the .htaccess file
    insert_with_markers(
        $htaccess_path,
        'my-custom-directives',
        $custom_directives
    );
}

add_action('wp_cache_cleared', 'modify_wpsc_cache_dir_htaccess');

Maybe it comes in handy for anyone else in the future, who knows 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OSS Citizen This Pull Request was opened by an Open Source contributor. [Plugin] Super Cache A fast caching plugin for WordPress. [Pri] Low [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants