Managing Cache Expirations

When I checked my website's performance using Google Webmaster Tools' PageSpeed analyzer, it highlighted that none of my resources were being cached. Here is the code snippet from my .htaccess file sourced directly from H5BP. I'm wondering if the expiration settings are correctly configured as per the below or if I need to specify explicit expirations for each individual file instead of general rules?

# ----------------------------------------------------------------------
# Expires headers (for improved cache control)
# ----------------------------------------------------------------------

# These expire headers are set in the far future.
# They assume versioning happens with filename-based cache busting
# It's also important to note that old proxies might cache incorrectly

# If you do not use filenames for versioning, consider reducing CSS and JS expires to something like
# "access plus 1 week".

<IfModule mod_expires.c>
  ExpiresActive on

# Consider whitelisting expires rules for better control 
  ExpiresDefault                          "access plus 1 month"

# cache.appcache requires re-requests in FF 3.6 (credits Remy ~Introducing HTML5)
  ExpiresByType text/cache-manifest       "access plus 0 seconds"

# Your main HTML document
  ExpiresByType text/html                 "access plus 0 seconds"

# Data files
  ExpiresByType application/json          "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType text/xml                  "access plus 0 seconds"

# Feeds
  ExpiresByType application/atom+xml      "access plus 1 hour"
  ExpiresByType application/rss+xml       "access plus 1 hour"

# Favicon (cannot change name)
  ExpiresByType image/x-icon              "access plus 1 week"

# Media: images, video, audio
  ExpiresByType audio/ogg                 "access plus 1 month"
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType video/mp4                 "access plus 1 month"
  ExpiresByType video/ogg                 "access plus 1 month"
  ExpiresByType video/webm                "access plus 1 month"

# HTC files  (css3pie)
  ExpiresByType text/x-component          "access plus 1 month"

# Webfonts
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  ExpiresByType application/x-font-ttf    "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"

# CSS and JavaScript
  ExpiresByType application/javascript    "access plus 1 year"
  ExpiresByType text/css                  "access plus 1 year"

</IfModule>

Answer №1

This appears to be a positive outcome.

It is possible that the mod_expires module is not installed (although this is very rare) or there may be other directives in your .htaccess or httpd.conf files that are overriding these settings. I recommend using a page speed tool to analyze the actual headers being sent by your files, and then providing that information here for further review.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking to fetch the title, description, and uploaded image all in one row and showcase them using PHP

My contact-form-submission.php file is responsible for inserting form data into a Database and uploading logos to the uploads folder. Here's a snippet of the code: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($ ...

Is there a way to create a Twitter Bootstrap panel with consistent padding and margins on all sides

I'm currently working on a webpage that involves using a background image with an inset opaque panel. My goal is to have the panel stretch all the way down to the bottom of the page, with some padding at the bottom for spacing. Additionally, I want ...

What is the best way to position my menu bar in the center of the

I've been struggling to center the menu bar and have tried everything I can think of. Below are the source files for the MENU BAR: I attempted the following code: <align=center> but unfortunately, it didn't work as expected. Curren ...

Submitting the form with a target of _blank will result in the form being submitted on both a

I am currently working on a form that includes both a "Submit" button and a "Preview" button. While the submit button is functioning correctly, I am experiencing an issue with the Preview button. When clicked, it opens up a new page with the preview as in ...

Transform an xlsx document into a HTML file using VBscript or batch script

After extensive research, I have come up empty-handed in finding a solution to the issue I am facing. The problem at hand is that I have an Excel file in .xlsx format that needs to be converted to .html on a regular basis throughout the day. Once converte ...

Creating dynamic visual effects using Jquery to showcase a sequence of outcomes

I am currently working on animating the results of a database query using jQuery. My goal is to have it display similar to Soh Tanaka's web tutorial example, where the element expands when hovered over and fills the parent element when clicked. I wa ...

Creative ways to use images as borders with CSS in React JS

import React, { Component } from 'react'; class BigText extends Component { constructor(props) { super(props); this.state = { title: '', text: '', summary: '' ...

My custom CSS in React is being overshadowed by the default Bootstrap styles

View project image Currently working on a React project that requires Bootstrap. However, I am facing issues with Bootstrap overriding my custom CSS. Some default Bootstrap styles are affecting my headings. I have attempted various solutions such as placi ...

What is the best way to center a div vertically on the page?

I've utilized Bootstrap 3 to create this row: <div class="cart"> <div class="row border"> <div class="col-md-8 desc pad itemsheight"> <div class="col-md-12"> <!-- react-text: 141 -->Docos <!-- /react ...

Guide for successfully implementing Bootstrap 5.3 popovers

I am in the process of designing a website with a variety of popovers, such as: <a tabindex="0" data-bs-toggle="popover">popover 1</a> <a tabindex="0" data-bs-toggle="popover">popover 2</a> H ...

Is it possible to disable a function by clicking on it?

I currently have a website that is utilizing the following plugin: This plugin enables an image to be zoomed in and out through CSS transforms, with default controls for zooming in and out. My goal is to incorporate a reset button that returns the image ...

Enable the Angular button only when the radio button has been selected

Just starting out with Angular and I have a query. This is a scenario for my project at work. https://i.stack.imgur.com/R3SxA.png In this screenshot, I want to enable the "ajouter" button when at least one radio button is selected in the secure chest (s ...

What is causing the divs to stack vertically instead of aligning horizontally?

I have encountered an issue with the layout of my HTML code. The inner divs are appearing in a lower row instead of horizontally inside the outer div with horizontal scrolling. I have already tried using properties like white-space:nowrap, but the proble ...

Spacing placeholder

Is there a way to leave the placeholder text in place while typing and have it extend forward as I type? For example, if I type 100 spaces and then "INX", it should look like this: 100 INX So that as I type "100." the "INX" moves forward, resulting in: ...

"Utilizing the 8-column layout feature in Twitter Bootstrap

Is it possible to set up 8 equal columns using the latest version of Twitter bootstrap? I know how to create 4 equal columns but I am struggling with figuring out how to achieve 8: <div class="col-sm-12"> <div class="row"> ...

CSS code that fixes a textarea at the bottom of a div

I need help placing a textarea at the bottom of a fixed div: <div id=msg> <div id=content> aaaaaaaannnnnnnnnn<br> aaaaaaaannnnnnnnnn<br> aaaaaaaannnnnnnnnn<br> </div> <div id=text> <textar ...

Exploring Webpack: Unveiling the Contrasts Between Production and Development CSS Bundles

Can you explain the differences in CSS between production and development when compiling with webpack? I've noticed that the production stylesheet seems to consider the entire website, whereas the development mode appears to only focus on the specifi ...

The Python error message, "JSONDecodeError: Expecting value: line 1 column 1 (char 0)," indicates that there

What is causing this error to occur? Are there any alternative methods available for converting it into a json file? import requests import json url = 'https://finance.yahoo.com/quote/AMZN/balance-sheet?p=AMZN&.tsrc=fin-srch' r = requests. ...

Differences between Firefox and Webkit browsers when it comes to scrolling - How side navigation, text truncation, and

Scrollbar appearance is causing an issue across different browsers. The truncated text in my side-navigation component is not displaying correctly on Firefox and IE browsers. View this fiddle on both Chrome and Firefox: https://jsfiddle.net/d84b9m49/10/ ...

Taking a segmented snapshot of a canvas using a flexible design scheme

I am working with a canvas that contains multiple div elements representing different sections of the canvas. However, when I capture these sections, they do not appear exactly as displayed on the screen. How can I track and accurately capture the div area ...