Why isn't Leverage browser caching not working for Javascript?

insnetflix
coronavirus news
cdc
cdc coronavirus

When running my site through the Google page speed test it says I need "Leverage browser caching Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network."

It then lists my internal Javascript files, why does the below not work and fix this?

This is how much htaccess file looks:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

<FilesMatch "\\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl|jpg|png|gif)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>

Thanks

You have specified that files of type text/x-javascript should be cacheable, but have you told the webserver how to recognise such files? As DanFromGermany says, the mimetype really should be application/javascript however within your webserver this is just an arbitrary label. Your webserver may already be configured to recognise files ending in .js as javascript, in which case its simply a matter of changing the corresponding line in the mod_expires block. You can see the mimetype being returned by webserver in firebug, iehttpheaders, using wireshark to monitor a connection or with wget / curl from the command line.

If your webserver is returning something other than application/javascript or text/x-javascript then check for an entry in the mime.types file in the directory containing your apache config.

Stefan Al: Why isn't the Netherlands underwater?, Why isn't the Netherlands underwater? Share this idea. Facebook. LinkedIn. Twitter. Created with Sketch. WhatsApp. Email. But that isn’t true for every interesting set of numbers. As an example, let’s look at the set of numbers of the form a + b √-5, or a +i b √5, where a and b are both integers and i is the

The official mime-type for Javascript is application/javascript, try this instead.

Source http://www.rfc-editor.org/rfc/rfc4329.txt

The x- stands for "experimental" and is not used with Javascripts anymore.

All of those combinations are either deprecated, obsolete or outdated:

text/x-javascript
text/javascript
application/x-javascript
application/ecmascript

There are more wrong mime-types in your config:

Wrong: image/x-icon Right: image/vnd.microsoft.icon

Source: http://www.iana.org/assignments/media-types/image/vnd.microsoft.icon

Wrong: application/x-pdf Right: application/pdf

Source: https://tools.ietf.org/html/rfc3778

Why Isn't Netflix Working, Due to the COVID-19 crisis thousands of our customer support agents are now having to work from home, making it harder to support your calls. So we are  In order to look for factors associated with ultraprocessed food that might cause weight gain, Hall recruited 20 adults between the ages of 18 and 45 to move into an inpatient ward at the N.I.H

Check your hosting configuration. I was using Cpanel's "SuperCacher services": static cache Dynamic cache Memcache

they were overriding my .htaccess settings and caused this issue. once i disabled them the issue went away.

As The Coronavirus Crisis Heats Up, Why Isn't America , Usually in health emergencies — HIV, vaping and more — the Centers for Disease Control and Prevention is key to shaping policy and  Why Your New Hard Drive Isn’t Showing Up in Windows (and How to Fix It) Jason Fitzpatrick @jasonfitzpatric Updated July 3, 2017, 4:24pm EDT.

Why isn't the Netherlands underwater? - Stefan Al, Dig into the incredible engineering of the Netherlands' Delta Works— the most sophisticated flood prevention system in the world. -- In January  Why isn't my Internet Explorer working? I have network and everything. It just turn it on so I have to you Firefox which perfectly works fine.

Why isn't the UK Testing Enough?: Why the UK is missing , Globe Collection: https://tldrnews.co.uk/product-category/badges/globe/ TLDR Store: https://tldrnews.co.uk/store Learn About Our Funding:  Stupid question… Why isn’t hand sanitizer back on store shelves? I can understand how all of the product in stock as of a week ago got sold. But the production lines are still running. …

In a Crisis, Radio Should Be Bigger Than Ever -- So Why Isn't It , In a Crisis, Radio Should Be Bigger Than Ever — So Why Isn't It? Terrestrial music stations have a major cultural opportunity right now, but  Russia says there are 438 known infections nationwide - but there have been 71 new cases in the past 24 hours and all of them in Moscow. However, there's suspicion abroad about the relatively

Comments
  • I have tried this but still no luck, I am on 1and1 and it looks like it uses application/x-javascript.
  • 1and1 hosting is appallingly bad, however the issue is not insurmountable if you can apply changes via htaccess. Just change the line in the mod_expires to match the mimetype the webserver is using.
  • It uses application/x-javascript which was already there, so it still isn't working for some reason.
  • Erm actually we talked about text/x-javascript, application/javascript but not application/x-javascript
  • There's no obvious reason why your config would work for other filetypes but not for javascript: you could try changing the values to confirm whether the htaccess file is having any impact at all, but then would reverse engineering the problems with 1and1's hosting help to fix the problem? Similarly there are other ways to make the content cacheable, but you are paying 1and1 for support - get them to advise.
  • I have tried this but still no luck, I am on 1and1 and it looks like it uses application/x-javascript.