Skip to content

Cache control headers are missing when SDC is not pre-generated #25578

Closed
@ihor-sviziev

Description

@ihor-sviziev

Preconditions (*)

  1. Apache 2.4 + php 7.2
  2. Magento 2.3.3 or 2.3-develop
  3. Magento mode: default, developer OR production with enabled SCD on demand and without running static content deploy

This issue isn't reproducing in production mode with compiled static content and not reproducing with nginx+php_fpm.

Steps to reproduce (*)

Case 1:

  1. Open Google Chrome developer tools
  2. Navigate to homepage
  3. In Google Chrome dev tools looks at any .js file (I checked on domReady.js file), look at "Response Headers" section
  4. Refresh the page, find the same JS file, looks at "Response Headers"

Case 2:
Try to curl some js file from Magento/blank two times(because you never request it before):
image

Expected result (*)

  1. First time file should contains Cache-Control header
  2. Second time should also contains Cache-Control header

Actual result (*)

  1. At first time Cache-Control header is missing
    image

  2. At second time - this header is there
    image

Additional info

In case if we'll have CDN - first response will be cached for many people and browser will not cache JS files in browser's cache. Also there are another headers missing (see screenshots) that could create incorrect behavior.

This issue caused by redirecting to static.php file when real .js file doesn't exists, and adding Cache-Control header isn't applying.

<FilesMatch .*\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$>
Header append Cache-Control public
</FilesMatch>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Framework/CacheIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P3May be fixed according to the position in the backlog.Progress: doneReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions