Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8691629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:09:32+00:00 2026-06-13T00:09:32+00:00

I’m trying to learn how to use .htaccess to manipulate my headers and, in

  • 0

I’m trying to learn how to use .htaccess to manipulate my headers and, in Google’s words, “leverage browser caching” to improve pageload times. The code I’ve experimented with is this:

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\.(js|css)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\.(html|php)$">
Header set Cache-Control "max-age=14400, public"
</FilesMatch>

For some reason, this is causing the entire website to throw a 500 error. In case it makes any difference, I’ve inserted this code very early in the .htaccess file, before some authentication logic that requires a password for certain subdomains and a long list of 301 RewriteEngine redirects, because this website was recently reorganized and a lot of URLs have changed.

Do you know why this is causing an error? I more or less copied the code from a blog and edited it to suit my needs. The 500 error also doesn’t crop up immediately after I update the .htaccess file, which to me implies that the error is starting AFTER the Apache server’s default four-hour cache expiry header lapses.

EDIT 10-17-2012:

Having tried adding and removing this code a couple of times now, I’ve confirmed that the headers DO WORK, albeit briefly. Using FireBug with PageSpeed, I can see that the max-age settings are being correctly applied to the files. Then after a while, as I’ve mentioned before, the website CHANGES to all 500, all the time.

Another thing worthy of note: I’m actually trying to test the new headers on a password protected test subdomain before rolling it out to the main site. As far as I can tell it looks like for some reason, after updating the .htaccess on the SUBDOMAIN (which even runs out of its own folder, separate from /public_html/), the MAIN (www) site breaks.

It’s possible that I’m doing something wrong, or accidentally uploading to the main site when I think I’m updating the test subdomain, but I’m becoming hesitant to risk more downtime on the main site over this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:09:33+00:00Added an answer on June 13, 2026 at 12:09 am

    It’s possible my 500 errors have nothing to do with the caching code, but with my site’s Control Panel. Apparently, just accidentally clicking on its built-in .htaccess editor menu causes it to edit my own hand-coded file and shuffle lines around to an order IT likes to see them in for use with its own tools. This is breaking the site with or without the Cache-Control lines.

    I’ll try testing things one more time, and if all goes well this problem will be solved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.