Problem/Motivation

.htaccess ExpiresDefault is intended for static content rather than 301 redirects.

# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600

However, when adding 301 redirects in Drupal's .htaccess file, the same 2 weeks will be applied.

$ curl -sIXGET http://www.mysite.com | grep -i 'cache\|http\|age'
HTTP/1.1 301 Moved Permanently
Location: https://www.mysite.com/
Cache-Control: max-age=1209600
Age: 60
X-Cache: HIT
X-Cache-Hits: 2

Proposed resolution

The suggestion here is we update the .htaccess file to indicate this because it can be really confusing to realize not only files but also redirects are going to be cached for 2 weeks.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

CommentFileSizeAuthor
clarify-2-weeks-redirect-caching.patch358 bytesanavarre

Comments

anavarre created an issue. See original summary.

anavarre’s picture

Issue summary: View changes

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

Title: .htaccess 301s get the ExpiresDefault value of 2 weeks instead of the Drupal value » Document that .htaccess 301s get the ExpiresDefault value of 2 weeks instead of the Drupal value
Category: Bug report » Task
Priority: Normal » Minor
Issue tags: +Bug Smash Initiative, +Novice

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Status: Active » Reviewed & tested by the community

Confirming this is still relevant. Still the 2 weeks seems much to low having a look at Google Pagespeed or GTMetrix recommendations that should be ~1Y instead!

If that's a reason to split this for redirects, please set this back to NW. I've opened a separate issue for a higher ExpiresDefault value: #3311406: .htaccess ExpiresDefault (2W) is much too low. Should be ~1Y

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I've backported this to 9.5.x as although it is an htaccess change it is only a comment. Therefore I don't believe this issue is worth a CR telling people to update their .htaccess files.

Committed and pushed 104b0e0807 to 10.1.x and d603c6dbed to 10.0.x and 04c799d13b to 9.5.x. Thanks!

  • alexpott committed 104b0e0 on 10.1.x
    Issue #3079404 by anavarre: Document that .htaccess 301s get the...

  • alexpott committed d603c6d on 10.0.x
    Issue #3079404 by anavarre: Document that .htaccess 301s get the...

  • alexpott committed 04c799d on 9.5.x
    Issue #3079404 by anavarre: Document that .htaccess 301s get the...

  • alexpott committed c735738 on 10.1.x
    Issue #3079404 by anavarre: Document that .htaccess 301s get the...

  • alexpott committed 7069578 on 10.0.x
    Issue #3079404 by anavarre: Document that .htaccess 301s get the...

  • alexpott committed 6dfe9bf on 9.5.x
    Issue #3079404 by anavarre: Document that .htaccess 301s get the...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.