SEO Glossary/304-not-modified
Back to Glossary

304 Not Modified

A 304 Not Modified HTTP status code indicates that a requested resource hasn't changed, allowing the client to use its cached version instead of re-downloading.

Definition

The 304 Not Modified is an HTTP status code that indicates a requested resource has not been modified since the last time it was accessed by the client. When a server responds with a 304 status code, it tells the browser or user agent that the cached version of the resource is still valid and can be used instead of downloading the resource again.

How 304 Not Modified Works

The 304 status code is part of HTTP's caching mechanism and works in conjunction with conditional requests. Here's the typical flow:

  1. Initial Request: A client requests a resource for the first time
  2. Server Response: The server sends the resource with caching headers like Last-Modified or ETag
  3. Subsequent Request: The client makes another request with conditional headers (If-Modified-Since or If-None-Match)
  4. Server Check: The server compares the conditional headers with the current resource state
  5. 304 Response: If unchanged, the server returns a 304 status code without the resource body

Key Characteristics

  • No Response Body: 304 responses contain only headers, no content body
  • Bandwidth Efficient: Reduces data transfer by leveraging cached content
  • Fast Response: Significantly faster than downloading the full resource
  • Cache Validation: Confirms the validity of cached resources

Common Conditional Headers

If-Modified-Since

Used with the Last-Modified response header to check if a resource has been modified since a specific date.

If-Modified-Since: Wed, 21 Oct 2023 07:28:00 GMT

If-None-Match

Used with the ETag response header to check if the entity tag has changed.

If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"

SEO Implications

Positive Impact on SEO

Improved Page Load Speed

  • Faster loading times due to reduced data transfer
  • Better user experience signals to search engines
  • Contributes to Core Web Vitals metrics

Server Resource Optimization

  • Reduces server load and bandwidth consumption
  • Allows servers to handle more concurrent requests
  • Improves overall site performance

Crawl Budget Efficiency

  • Search engine bots can crawl more pages with saved resources
  • More efficient use of allocated crawl budget
  • Better indexing coverage for large websites

Potential SEO Considerations

Content Freshness

  • Ensure caching strategies don't prevent search engines from seeing updated content
  • Balance between caching efficiency and content freshness
  • Monitor for over-aggressive caching that might hide important updates

Best Practices for Implementation

Server Configuration

Set Appropriate Cache Headers

Cache-Control: max-age=3600, must-revalidate
Last-Modified: Wed, 21 Oct 2023 07:28:00 GMT
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"

Configure Conditional Request Handling

  • Ensure your server properly handles If-Modified-Since and If-None-Match headers
  • Implement accurate comparison logic for determining resource modifications
  • Return appropriate 304 responses when content hasn't changed

Content Strategy

Static Resources

  • Apply 304 caching to CSS, JavaScript, images, and other static assets
  • Use versioning for static files to control cache invalidation
  • Implement proper cache-busting mechanisms for updated resources

Dynamic Content

  • Carefully consider caching strategies for frequently updated content
  • Use ETags for dynamic content that changes unpredictably
  • Balance between performance and content freshness

Technical Implementation Examples

Apache .htaccess Configuration

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType image/png "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(css|js|png|jpg|jpeg|gif|ico|svg)$">
        Header set Cache-Control "public, max-age=2592000, must-revalidate"
    </FilesMatch>
</IfModule>

Nginx Configuration

location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg)$ {
    expires 30d;
    add_header Cache-Control "public, max-age=2592000, must-revalidate";
    add_header Last-Modified $date_gmt;
    if_modified_since exact;
}

Monitoring and Testing

Tools for Testing 304 Responses

Browser Developer Tools

  • Check Network tab for 304 status codes
  • Monitor cache hit rates and response times
  • Verify proper header implementation

Command Line Testing

# Test with curl
curl -I -H "If-Modified-Since: Wed, 21 Oct 2023 07:28:00 GMT" https://example.com/style.css

# Test with wget
wget --server-response --header="If-Modified-Since: Wed, 21 Oct 2023 07:28:00 GMT" https://example.com/style.css

Performance Monitoring

Key Metrics to Track

  • Cache hit ratio for 304 responses
  • Average response times for cached vs. non-cached requests
  • Bandwidth savings from 304 responses
  • Impact on Core Web Vitals scores

Common Issues and Troubleshooting

Problems with 304 Implementation

Incorrect Last-Modified Headers

  • Ensure Last-Modified headers are accurate and consistent
  • Avoid setting future dates or inconsistent timestamps
  • Validate date formatting follows HTTP specifications

ETag Mismatches

  • Verify ETag generation is consistent across server instances
  • Ensure ETags change when content is modified
  • Check for load balancer interference with ETag headers

Cache Control Conflicts

  • Resolve conflicts between different cache control directives
  • Ensure cache headers work correctly with CDNs and proxies
  • Test caching behavior across different client types

Debugging 304 Responses

Server Logs Analysis

  • Monitor server logs for 304 response patterns
  • Identify resources that should but don't return 304 responses
  • Check for unusual caching behavior or errors

Header Validation

  • Use online tools to validate HTTP headers
  • Test conditional requests manually
  • Verify proper header syntax and values
  • 200 OK: Resource modified, full content returned
  • 301/302 Redirects: Resource moved, different from caching
  • 404 Not Found: Resource doesn't exist
  • 500 Internal Server Error: Server-side issues affecting caching

Conclusion

The 304 Not Modified status code is a crucial component of efficient web performance and SEO optimization. Proper implementation reduces bandwidth usage, improves page load times, and enhances user experience while allowing search engines to crawl more efficiently. By understanding and correctly implementing 304 responses, websites can achieve better performance metrics and potentially improved search engine rankings through enhanced user experience signals.

Ready to Optimize Your Website?

Use our free SEO analysis tool to see how well your site implements these concepts