I just upgraded from a dev version of 2.7 to v2.11, and this warning started appearing in my status report. Upgraded to the latest -dev of HTTPRL at the same time. Drupal version is 7.38.

This site confirms the diagnosis: https://www.feedthebot.com/tools/if-modified/

I found the previous issue relating to this warning from two years ago: https://www.drupal.org/node/2143131

The suggestions made there haven't helped. The patch won't apply (not surprised) and there is no Header unset Last-Modified line to remove from .htaccess.

Any other suggestions?

Thanks

CommentFileSizeAuthor
#3 advagg-2510566-2-etag-test.patch6.35 KBmikeytown2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

The Last-Modified header is needs to be set in order for it to work.

I should look into setting etags as well and testing; as that will give a 304 as well.

  • mikeytown2 committed 9f74634 on 7.x-2.x
    Issue #2510566 by mikeytown2: Add in checks for Etags.
    
mikeytown2’s picture

Status: Active » Fixed
FileSize
6.35 KB

there is no Header unset Last-Modified line to remove from .htaccess.

That advice only is given because that string was found inside the .htaccess file. Code in question

        // Get path to advagg .htaccess file.
        $files = array(
          $file_path . '/.htaccess',
          DRUPAL_ROOT . '/.htaccess',
        );

        // Check for bad .htaccess files.
        $bad_config_found = FALSE;
        foreach ($files as $count => $file) {
          if (!file_exists($file)) {
            continue;
          }
          $contents = file_get_contents($file);
          if (strpos($contents, 'Header unset Last-Modified') !== FALSE) {
            $bad_config_found = TRUE;
            $requirements['advagg_' . $type . '_last-modified_' . $key . $count] = array(
              'title' => $t('Adv CSS/JS Agg - Last-Modified'),
              'severity' => REQUIREMENT_WARNING,
              'value' => $t('The Last-Modified header is not being sent out by your web server.'),
              'description' => $t('The web servers configuration will need to be adjusted. The server should have sent out a Last-Modified header. Remove "Header unset Last-Modified" inside this file to fix the issue: @file', array('@file' => $file)),
            );
          }
        }

Also see if any updates need to be ran. I have some updates that remove this from the htaccess file when coming from an older version of advagg.

Patch adds in etag support.

millionleaves’s picture

Thanks. The patch adds the etag check which generates a similar warning in the Status Report.

I guess what's unclear to me is - what adjustment needs to be made to the .htaccess? Searching around for Last-Modified indicates that ModExpires needs to be enabled, which it is. ExpiresActive is present in the .htaccess. What else needs to be done - or - am I on the wrong track?

mikeytown2’s picture

css htaccess

<FilesMatch "^css__[A-Za-z0-9-_]{43}__[A-Za-z0-9-_]{43}__[A-Za-z0-9-_]{43}.css(\.gz)?">
  # Use ETags.
  FileETag MTime Size
  
  # Use Expires Directive.
  <IfModule mod_expires.c>
    # Enable expirations.
    ExpiresActive On
    # Cache all aggregated css files for 52 weeks after access (A).
    ExpiresDefault A31449600
  </IfModule>
  
  <IfModule mod_headers.c>
    # Serve correct content type.
    Header set Content-Type text/css
    <IfModule !mod_expires.c>
      # Set a far future Cache-Control header to 52 weeks.
      Header set Cache-Control "max-age=31449600, no-transform, public"
    </IfModule>
    <IfModule mod_expires.c>
      Header append Cache-Control "no-transform, public"
    </IfModule>
  </IfModule>
  ForceType text/css
</FilesMatch>

js htaccess

<FilesMatch "^js__[A-Za-z0-9-_]{43}__[A-Za-z0-9-_]{43}__[A-Za-z0-9-_]{43}.js(\.gz)?">
  # Use ETags.
  FileETag MTime Size
  
  # Use Expires Directive.
  <IfModule mod_expires.c>
    # Enable expirations.
    ExpiresActive On
    # Cache all aggregated js files for 52 weeks after access (A).
    ExpiresDefault A31449600
  </IfModule>
  
  <IfModule mod_headers.c>
    # Serve correct content type.
    Header set Content-Type application/javascript
    <IfModule !mod_expires.c>
      # Set a far future Cache-Control header to 52 weeks.
      Header set Cache-Control "max-age=31449600, no-transform, public"
    </IfModule>
    <IfModule mod_expires.c>
      Header append Cache-Control "no-transform, public"
    </IfModule>
  </IfModule>
  ForceType application/javascript
</FilesMatch>

This will use Etag as well as Last-Modified. Hopefully one of them (Etag, Last-Modified) works for you.

Status: Fixed » Closed (fixed)

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

pedrosp’s picture

Version: 7.x-2.11 » 7.x-2.x-dev

I have (twice actually) the same warning on Status report, using Advagg 7.x-2.14, or last dev as of today.
My config D7.38 and Nginx/1.8.0 (a-la-perusio):
"Adv CSS/JS Agg - If-Modified-Since The If-Modified-Since (Last-Modified) header is being ignored by your web server.
The web servers configuration will need to be adjusted. The server should have responded with a 304, instead a 200 was returned."

However, when tested with https://varvy.com/tools/if-modified/ (Does your webpage support the 304 If Modified Since HTTP header?) the answer is YES.
This tool checked your HTTP headers and received this response ... Last-Modified: Wed, 05 Aug 2015 07:07:19 GMT
Tool then rechecked looking for if modified since support and found it... Server Response HTTP/1.1 304 Not Modified

Any clues ? Maybe the status report is not having this response asking from localhost instead of "external" ping ?
Thanks.

mikeytown2’s picture

Status: Closed (fixed) » Active
mikeytown2’s picture

Status: Active » Closed (fixed)

pedrosp
Looking into this more and can you open up a new support request for the issue you are having?

pedrosp’s picture