Skip to main content
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
added 305 characters in body
Source Link
albertski
  • 3.5k
  • 4
  • 25
  • 48

Google complains toon leverage browser caching buton the following files:

Leverage browser caching for the following cacheable resources:
https://www.googletagmanager.com/gtm.js?id=GTM-xxxxxx (15 minutes)
https://www.googleadservices.com/pagead/conversion_async.js (60 minutes)
https://www.google-analytics.com/analytics.js (2 hours)

I have the following in my .htaccess file which should set all files to 2 weeks:

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

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

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

I verified that I have the mod_expires module enabled.

In Cloudflare I have Browser Cache Expiration set to 2 hours.

Google complains to leverage browser caching but I have the following in my .htaccess file which should set all files to 2 weeks:

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

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

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

I verified that I have the mod_expires module enabled.

In Cloudflare I have Browser Cache Expiration set to 2 hours.

Google complains on leverage browser caching on the following files:

Leverage browser caching for the following cacheable resources:
https://www.googletagmanager.com/gtm.js?id=GTM-xxxxxx (15 minutes)
https://www.googleadservices.com/pagead/conversion_async.js (60 minutes)
https://www.google-analytics.com/analytics.js (2 hours)

I have the following in my .htaccess file which should set all files to 2 weeks:

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

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

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

I verified that I have the mod_expires module enabled.

In Cloudflare I have Browser Cache Expiration set to 2 hours.

Source Link
albertski
  • 3.5k
  • 4
  • 25
  • 48

Google Page Speed Insights recommends Leverage browser caching

Google complains to leverage browser caching but I have the following in my .htaccess file which should set all files to 2 weeks:

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

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

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

I verified that I have the mod_expires module enabled.

In Cloudflare I have Browser Cache Expiration set to 2 hours.