I get this on my settings page now.

How can I set the headers correctly?

Adv CSS/JS Agg - Cache-Control The cache-control's max-age header being sent by your web server is not at least 1 year in the future.
The web servers configuration should be adjusted only for AdvAgg files. Was looking that the max-age second counter is over 31,536,000 (1 year), actually got NULL.
Warning
Adv CSS/JS Agg - Expires The expires header being sent by your web server is not at least 1 year in the future.
The web servers configuration should be adjusted only for AdvAgg files. Was looking for a second counter over 31,536,000 (1 year), actually got NULL.

Comments

mikeytown2’s picture

If your using Apache, add this to your .htaccess file at the webroot level.

<FilesMatch "^(css|js)__[A-Za-z0-9-_]{43}__[A-Za-z0-9-_]{43}__[A-Za-z0-9-_]{43}.(css|js)(\.gz)?">
  # No mod_headers
  <IfModule !mod_headers.c>
    # Use Expires Directive.
    <IfModule mod_expires.c>
      # Do not use ETags.
      FileETag None
      # Enable expirations.
      ExpiresActive On
      # Cache all aggregated css/js files for 480 weeks after access (A).
      ExpiresDefault A290304000
    </IfModule>
  </IfModule>

  <IfModule mod_headers.c>
    # Set a far future Cache-Control header to 480 weeks.
    Header set Cache-Control "max-age=290304000, no-transform, public"
    # Set a far future Expires header.
    Header set Expires "Tue, 20 Jan 2037 04:20:42 GMT"
    # Do not use etags for cache validation.
    Header unset ETag
  </IfModule>
</FilesMatch>
socialnicheguru’s picture

does this go in the .htaccess file in

# Rules to correctly serve gzip compressed CSS and JS files.
# Requires both mod_rewrite and mod_headers to be enabled.

mikeytown2’s picture

Reference for those comment lines inside of core's .htacces file: http://drupalcode.org/project/drupal.git/blob/refs/heads/7.x:/.htaccess#...

I would put it at the very bottom of the .htaccess file; after the last </IfModule>. Note that if you have .htaccess turned on, the code in #1 will most likely not make a difference as the .htaccess file inside of the advagg_css & advagg_js files directory should already be applied.

If your .htaccess directives have been moved into the httpd.conf file then You need to put the code in #1 in there. Restart of apache will be required.

If your using the import method inside of httpd.conf, then putting the code in #1 inside of core's .htaccess file should work. Restart of apache will be required.

Notes:
https://drupal.org/node/43788
https://groups.drupal.org/node/22864
#2088563-6: Yslow gives: Grade F on Add Expires headers

mikeytown2’s picture

Status: Active » Fixed
StatusFileSize
new2.71 KB

Following patch has been applied. Adds documentation to the readme file

Status: Fixed » Closed (fixed)

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

bzitzow’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work
StatusFileSize
new80.34 KB

In attempting to resolve these same warnings I found the following issue:

a) https://www.drupal.org/node/2193333#comment-8469991

  • Applied the patch to .htaccess

b) I also reviewed the updated README.txt (from this issue) and updated the .htaccess per the README.txt

I then deployed the code to pantheon, cleared the cache, and the warnings are still being logged.

(See attached screenshot)

mikeytown2’s picture

Status: Needs work » Closed (fixed)

@bzitzow
Looks like something else is setting it to 1 week (604800 seconds). Can you find that value (604800) in your configuration anywhere?

Also open a new issue under the support request category. I've re-closed this one.

SoportePRO’s picture

When using Windows Server, IIS... you need to edit your Drupal 7 website root web.config file and add inside section:

        <staticContent>
            <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" />
        </staticContent>

This complete eliminate this warning.

I hope this help someone.

osopolar’s picture

Status: Closed (fixed) » Fixed

When using apache, make sure that module expires is enabled, for example with sudo apache2ctl -M |grep expires. If it is not enabled, enable it with sudo a2enmod expires.

Should this be documented in README.txt too?

mikeytown2’s picture

@osopolar
The status report page will check for mod_headers by using the apache_get_modules() function. mod_expires isn't required from my tests but I could have been mistaken.

osopolar’s picture

Status: Fixed » Needs review

I added an follow up issue, as apache_get_modules() is not available for php as CGI/FastCGI: #2612082: Make clear that for apache mod_headers or mod_expires needs to be enabled.

mikeytown2’s picture

Status: Needs review » Fixed

Putting this issue back to fixed. Will followup on the following issue.

Status: Fixed » Closed (fixed)

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

Rob T’s picture

Mike's .htaccess snippet for Apache in #1 worked like a charm. Thanks.

mikeytown2’s picture

The readme has an always up to date root level .htaccess rules: http://cgit.drupalcode.org/advagg/tree/README.txt#n556

numerabilis’s picture

What about Nginx? What should I put in conf file?

mikeytown2’s picture

uniweb’s picture

#1 works perfectly for me, thanks a lot !