Rails 3.1 on Apache, PageSpeed ​​says "Specify a cache validator" when using the Apache Pipeline apache configuration

I see a conflict between the Rails 3.1 recommendations and the Google PageSpeed ​​offer for managing cached assets.

Asset Pipeline 3.1 Rails offers an Apache server configuration solution here

The main apache configuration bit:

<LocationMatch "^/assets/.*$"> # Some browsers still send conditional-GET requests if there a # Last-Modified header or an ETag header even if they haven't # reached the expiry date sent in the Expires header. Header unset Last-Modified Header unset ETag FileETag None # RFC says only cache for 1 year ExpiresActive On ExpiresDefault "access plus 1 year" </LocationMatch> 

Everything works, but when I start Google PageSpeed, it complains that I have to "Specify validator validation" by installing either Last-Modified or ETag , listing all the files in the resources folder.

Note Header unset Last-Modified satisfies the PageSpeed ​​parameter.

I quickly checked out the various pageloads and, at least in Chrome, it did not seem to matter - the assets were cached anyway.

Does anyone know what is suitable?

+3
source share
1 answer

This code has been cut and pasted from Rails source code for convenience. (It was me who copied it).

I checked Steve Souders (thanks, Steve) and he said the following:

You cannot undo Last-Modified. I put the person who wrote that they clicked "Reload" to perform their testing. When you click Restart, you explicitly tell the browser to send a conditional GET. (see this )

ETag has the same problem (if you click "Reload", it will send a conditional GET). But he has another problem, which probably means you should disable ETag. The problem is that the default ETag syntax for Apache and IIS causes unnecessary validation errors and wasted bytes. You should either configure the syntax to solve these problems, but for most people, it’s easier to just disable ETags. (see this )

I am updating Rails docs!

+9
source

Source: https://habr.com/ru/post/901046/


All Articles