Add Expired Headers - is something blocking this?


#1

Hi.

I’m using Wordpress and I have developed an .htaccess plugin for Wordpress. It modifies the .htaccess file for Apache sites to improve performance and security.

I developed this plugin about half a year ago and tested it during that time and now on localhost.

For some reason, no Expired Header settings take effect work on the Cloud9 site.

Is there something blocking this from working?

I’m trying to run Yslow against my pages to check the results and Expired Headers for assets files, etc. are not taking affect., but I know my settings work. I’ve also tried Page Speed Insights just to double check there.

Here is a snippet of expired headers I am using…

ExpiresByType text/plain "access 1 month"
ExpiresByType text/richtext "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/x-js "access 1 month"
ExpiresByType text/x-javascript "access 1 month"

#2

I’m assuming you’re running with the Apache runner and not the PHP built-in web server, is that right? You could try creating a new workspace, just with a simple Apache site and see if these settings work there.


#3

Thanks for the reply @bradydowling .

I looked into what you said, looking at the Project Settings (project.settings) and it looks like I am running the Apache runner and not the PHP built-in web server. But, I am new to that type of information/understanding this project.settings file.

Could you tell me if that is what I am running and how to tweak?

My settings file shows…

"run": {
        "@path": "/.c9/runners",
        "configs": {
            "@inited": true,
            "json()": {
                "WordPress": {
                    "command": "",
                    "debug": false,
                    "default": true,
                    "name": "WordPress",
                    "runner": "Apache httpd (PHP, HTML)"
                }
            }
        }
    },

Off top I was just guessing that I could add HTACCESS like so…??

"runner": "Apache httpd (PHP, HTML, HTACCESS)"

I did notice that no .htaccess settings seem to work, except if I write a syntax mistake then the server will error. So that leaves me not entirely sure.


#4

Just an update…

I think I understood what you were saying about the Runner vs. PHP built-in web server.

So what I did to test (and hope this is what you meant).

I created another workspace and instead of using the one click Wordpress install I chose the PHP, apache install.

Then I installed a simple HTML site.

Then I ran the Yslow against it, seeing its result and the need for expired headers.

Then I installed my .htaccess file to give those file their expired headers.

I still came out with the same result, which seems that no .htaccess changes are taking affect. I get the same results wether my .htaccess edits are present or not.

My PHP web server project.settings are…

"run": {
        "@path": "/.c9/runners",
        "configs": {
            "json()": {
                "PHP": {
                    "runner": "Apache httpd (PHP, HTML)",
                    "command": "",
                    "name": "Apache & PHP",
                    "default": true
                }
            },
            "@inited": true
        }
    },

#5

Yep, that’s exactly what I was talking about, thanks for doing that. Htaccess should work with Apache out of the gate as you’re running it. Can you copy paste your .htaccess file in here so I can make a report about this?


#6

Hi @bradydowling

This is still an issue (I’ve checked).

I wasn’t ready to give out my .htaccess edits then and don’t want to give my entire htaccess file because it is a plugin that I am going to release soon.

Below is a snippet that you can test, which is also what ensures to me the htaccess is not working. This portion, the mod_expires alone should put the expired headers on the site images and assets (css, js) but it doesn’t. This is what I was noticing that led me to conclude that the server wasn’t serving the htaccess settings.

`

ExpiresActive On
ExpiresDefault "access 1 month"

# ------------------------------------------------------------------------------------------------------------------------------------------------------
#   Text
# ------------------------------------------------------------------------------------------------------------------------------------------------------

ExpiresByType text/plain "access 1 month"
ExpiresByType text/richtext "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/x-js "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType text/x-component "access 1 month"
ExpiresByType text/xml "access 1 month"
ExpiresByType text/xsl "access 1 month"
ExpiresByType text/xsd "access 1 month"

# ------------------------------------------------------------------------------------------------------------------------------------------------------
#   Images
# ------------------------------------------------------------------------------------------------------------------------------------------------------

ExpiresByType image/x-icon "access 1 month"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/svg+xml "access 1 month"
ExpiresByType image/tiff "access 1 month"
ExpiresByType image/bmp "access 1 month"

# ------------------------------------------------------------------------------------------------------------------------------------------------------
#   Audios
# ------------------------------------------------------------------------------------------------------------------------------------------------------

ExpiresByType audio/mpeg "access 1 month"
ExpiresByType audio/x-realaudio "access 1 month"
ExpiresByType audio/wav "access 1 month"
ExpiresByType audio/wma "access 1 month"
ExpiresByType audio/midi "access 1 month"
ExpiresByType audio/ogg "access 1 month"

# ------------------------------------------------------------------------------------------------------------------------------------------------------
#   Videos
# ------------------------------------------------------------------------------------------------------------------------------------------------------

ExpiresByType video/mp4 "access 1 month"
ExpiresByType video/mpeg "access 1 month"
ExpiresByType video/quicktime "access 1 month"
ExpiresByType video/avi "access 1 month"
ExpiresByType video/asf "access 1 month"
ExpiresByType video/divx "access 1 month"

# ------------------------------------------------------------------------------------------------------------------------------------------------------
#   Applications
# ------------------------------------------------------------------------------------------------------------------------------------------------------

# Applications > Fonts

ExpiresByType application/x-font-otf "access 1 month"
ExpiresByType application/vnd.ms-opentype "access 1 month"
ExpiresByType application/x-font-ttf "access 1 month"
ExpiresByType application/font-woff "access 1 month"
ExpiresByType application/x-font-woff "access 1 month"
ExpiresByType application/x-font-opentype "access 1 month"
ExpiresByType application/vnd.ms-opentype "access 1 month"

# Applications > Javascripts

ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"

ExpiresByType application/x-gzip "access 1 month"

# Applications > Jsons

ExpiresByType application/json "access 1 month"

# Applications > Java

ExpiresByType application/java "access 1 month"

# Applications > Adobe Flash

ExpiresByType application/x-shockwave-flash "access 1 month"

# Applications > Open Documents (Office Applications)

ExpiresByType application/vnd.oasis.opendocument.database "access 1 month"
ExpiresByType application/vnd.oasis.opendocument.chart "access 1 month"
ExpiresByType application/vnd.oasis.opendocument.formula "access 1 month"
ExpiresByType application/vnd.oasis.opendocument.graphics "access 1 month"
ExpiresByType application/vnd.oasis.opendocument.presentation "access 1 month"
ExpiresByType application/vnd.oasis.opendocument.spreadsheet "access 1 month"
ExpiresByType application/vnd.oasis.opendocument.text "access 1 month"

# Applications > PDFs (Portable Document Format)

ExpiresByType application/pdf "access 1 month"

# Applications > Microsoft Programs

ExpiresByType application/msword "access 1 month"
ExpiresByType application/vnd.ms-write "access 1 month"
ExpiresByType application/vnd.ms-excel "access 1 month"
ExpiresByType application/vnd.ms-powerpoint "access 1 month"
ExpiresByType application/x-msdownload "access 1 month"
ExpiresByType application/vnd.ms-access "access 1 month"
ExpiresByType application/vnd.ms-project "access 1 month"
ExpiresByType application/vnd.ms-fontobject "access 1 month"

# Applications > Archives

ExpiresByType application/zip "access 1 month"
ExpiresByType application/x-tar "access 1 month"

`