Search This Blog

Tuesday, January 27, 2009

How to Compress PHP and Other Text-Based Files with 1&1 (and Other Shared Hosts)


If you have a shared Linux hosting package through 1&1, you have no doubt discovered that the usual method of changing your .htaccess file does not allow you to compress your files using Apache because 1&1 has disabled the mod_deflate and mod_gzip modules; you also cannot specify php values in .htaccess files in 1&1 shared packages, so a solution like this one also will not work. However, there is a solution that does work, and it works even on the most basic 1&1 Beginner’s Package.

Note: If you plan to implement the Minify! option I blog about in How to Easily Combine, Minify, and Cache JavaScript and CSS..., you can safely skip steps 1 and 2 and include only the first line shown in step 3.

Step 1:

Determine what your root path is; if you are using a 1&1 package, it will look something like this:
/kunden/homepages/12/d123456789/htdocs/
You can do that by creating a text file in Notepad or other editor,* entering the following lines, then saving it with as phpinfo (or whatever you want) followed by the .php extension.
<?php
phpinfo();
?>
(* If you’re using Notepad, you’ll probably want to put quotation marks around the name "phpinfo.php" when saving, to keep it from saving the file as phpinfo.php.txt.

Personally, after passing from Geany on Windows (used Notepad++ some), and Komodo Edit on Mac OSX, my editor of choice is now a customized version of vim. Incidentally, the three previously mentioned IDEs mutually rely on the Scintilla editor as their base.)

Now browse to the newly uploaded file with your web browser and search for DOCUMENT_ROOT. This variable will tell you what the exact path is to your server.

Step 2:

Now create another php file in the same way, this time adding the following information so that when you compress your CSS and JS files, they are served with the right headers, or else they will not load properly in Firefox and other browsers:
<?php
if (isset($_SERVER['SCRIPT_FILENAME'])) {
    $timestamp = filemtime(__FILE__);
    header('Last-Modified: ' . $timestamp);
    $expires = 60*60*24*14;
    header("Pragma: public");
    header("Cache-Control: maxage=".$expires);
    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
    header('Vary: Accept-Encoding');
    $pathinfo = pathinfo($_SERVER['SCRIPT_FILENAME']);
    $extension = $pathinfo['extension'];
    if ($extension == 'css') {
        header('Content-type: text/css');
    }    
    if ($extension == 'js') {
        header('Content-type: text/javascript');
    }
}?>
Make sure that you don’t space down between the lines or add an extra space at the end, and save this file as headers.php, uploading it to wherever you keep your scripts. For the sake of this example, I will assume that you store your scripts in a directory named webscripts.

[Update: As Brett reminds me in the comment below, you have now given PHP control of rendering your pages, so you will also need to include in this file any other header information you know you’ll need by declaring each header on its own line. For example, notice this extra line:

header('Vary: Accept Encoding');

Based on the readership of these articles, this will be particularly useful when optimizing for speed using a free tool like Google's Page Speed and the Yahoo! based YSlow. Add as many extra headers as you need, one per line.]

Step 3:

Create a third file, this time a PHP configuration file, entering the following information (though of course changed with the information you looked up in step 1 and whatever directory you use for step 2—unfortunately, you can’t use environmental variables in .ini files, as they are straight ASCII):
zlib.output_compression=1
auto_prepend_file=/kunden/homepages/12/d123456789/htdocs/webscripts/headers.php
Name your configuration file the conventional php.ini and save it. (If for some reason zlib.output_compression=1 doesn't work, try output_handler=ob_gzhandler instead.)

The first line tells the server to use PHP’s built-in g-zip handler for compression; the second line points to the exact location of the file you created in step 2: /kunden/homepages/12/d123456789/htdocs/ is the document root you located in step 1, and webscripts/ is the directory where you uploaded the headers.php script.

auto_prepend_file tells the server to automatically “prepend,” or “attach to the beginning of” all pages it serves (versus auto_append_file, which would “append,” or “attach to the end” of all files). The if/then conditional statements in step 2 ensures that the headers.php file will only attach headers if the file in question has a .css or .js extension.

Note: Check with your web host. With 1&1, at least, you will need to upload a copy of your php.ini file to EVERY directory containing files you want compressed.

Step 4:

Create an .htaccess file or modify your existing one by adding the following line (if you’re not familiar with an .htaccess file, see here):

CAUTION: If you plan to implement the Minify! solution I blog about in How to Easily Combine, Minify, and Cache JavaScript and CSS..., I do not recommend including the .css and .js file extensions on this line. Doing so processes these files twice, as Minify! already has its own mechanism for compressing files. And, as a result of double compression, certain versions of Internet Explorer choke and die silently.

AddType x-mapp-php5 .php .shtml .html .htm .txt .js .css
This line tells the server to process all the file extensions specified through PHP5; change it to x-mapp-php4 if you want to use PHP4 instead. You can add other extensions or take away from the ones here: whatever extensions are listed on the line after the x-mapp-php5 will be processed via PHP.

Note: On other Linux hosts, you may need to use php5-script instead of x-mapp-php5.

[June 4, 2011 Update: I was setting up my sister's site recently, also on a 1&1 Beginner’s Package, and the style sheets were not working correctly. The fix was to add this line to the .htaccess file immediately above the line shown in the example above:
RemoveHandler .css
I first tried removing all file extensions I was using, including .htm, but this caused problems. Just know that you have the option of removing file handlers and play around with it as needed.

Step 5:

Now test to see whether or not your pages are being compressed by using the free tool from GIDNetwork.

121 comments:

  1. i found that using this technique prevented my .htaccess from adding expiration headers to css and js files. i'm a bit of a noob, so my solution may not be the most elegant. i changed the headers.php file to:

    <?
    $pathinfo=pathinfo($_ENV['SCRIPT_FILENAME']);
    $extension=$pathinfo['extension'];
    $offset = 60 * 60 * 24 * 30;
    if($extension=='css'){
    header('Content-type: text/css; charset=utf-8');
    header("Expires: ".gmdate("D, d M Y H:i:s", time() + $offset)." GMT");
    }
    if($extension=='js'){
    header('Content-type: text/javascript; charset=utf-8');
    header("Expires: ".gmdate("D, d M Y H:i:s", time() + $offset)." GMT");
    }
    ?>

    ReplyDelete
  2. i forgot to say thanks for the ideas and that it did help a lot.

    ReplyDelete
  3. No problem, Brett. And you bring up a good point: PHP is now processing your files, so any file header information that you want sent will also need to be specified in your file, much as you have done. Thanks for passing along the new information. :)

    ReplyDelete
  4. Thanks a lot for this work - everything is working fine - except of the wp-frontend. I do not have the php.ini in the wp-admin-folders - but the layout of the dashboard and the editor is broken.

    Do you have an idea?

    Thanks a lor and many greetings from germany
    Oliver

    ReplyDelete
  5. Hello to you from America, Plerzelwupp.

    I suspect that if everything is working everywhere else but your admin panel, that it is because PHP is serving both your javascript and your css with "text/html" as the transfer type. Although, most modern browsers should handle the issue.

    If adding a php.ini in the admin folder doesn't pan out for you, my next suggestion is to go to the WordPress forum (http://wordpress.org/support/) and see if anybody's posted anything first, and, if not, ask for advice there.

    Hope that helps.

    ReplyDelete
  6. For 1and1 shared hosting an even easier solution is to just add the following line to the top of your index.php file:

    ob_start("ob_gzhandler");

    http://www.magentocommerce.com/boards/viewthread/46891/

    Although this probably only compresses the source file (Xhtml) and not the included assets (Css/js etc)

    ReplyDelete
  7. Well, that solution works on a page-by-page basis, unless you have a templating system that shares the main index.php file (as I assume is the case with Magento). If all other files use this file as the page template, simply including their own content, then you're good to go.

    However, you are correct: It will neither compress your script and css files nor any files that are not built into the index.php file.

    So the difference is that between site-wide compression that should work anywhere versus page-by-page compression that will work in some instances.

    ReplyDelete
  8. Hi,

    Using this and the minify doesnt work for my site in firefox. i am on 1and1 so added the line
    output_handler=ob_gzhandler
    to a new php.ini and now it isnt using css at all.
    Google site performace tells me "The following publicly cacheable, compressible resources should have a "Vary: Accept-Encoding" header: "
    how do i do this?

    My site is

    http:www.ourgoodlife.co.uk

    if that helps at all.

    Thanks in advance!

    ReplyDelete
  9. The only thing we are doing in the first and second steps in the directions above is specifying the path to the script that tests for the .css or .js extensions and serves up different headers if a match is found. The reason the directions say to skip these steps if using Minify! is that Minify! already has its own mechanisms for handling JS and CSS files.

    It sounds to me like you might have encountered an issue with Minify! itself. I would go to http://code.google.com/p/minify/ and check out the Wiki tab first, then post your question under Issues if that still doesn't resolve the issue. I wish I could be of more help. :(

    By the way, your site looks very nice and clean. ;)

    ReplyDelete
  10. thanks i will look into it!

    ReplyDelete
  11. Hmm. I've been working on the blog a bit and happened to re-read your question and realized that Brett's post--very first one--might contain a solution.

    Look at his top post as reference, then add the following line to it, once for each "if" block for the CSS and JS extensions:

    header("Vary: Accept-Encoding");

    That should work, though know I have not tested.

    ReplyDelete
  12. I found the site, in respect to this post, by looking for info on HTTP headers

    http://www.caucho.com/resin/admin/http-proxy-cache.xtp

    and found the info valuable, though it clearly wasn't written in PHP and I wanted to know definitely what server environment it was before passing along the link.

    It looked kinda interesting: an open-source Java and PHP server environment software.

    Particularly for the creative persons who have full administrative privileges on their servers and who aren't afraid to try new technologies, it might be just the thing. The two softs are Quercus and Resin, Quercus included with Resin.

    Resin is available in both a free, open-source model (GPL License) and a paid model starting at $699 per server/per year, providing full technical support.

    Main download page is here: http://www.caucho.com/download/

    ReplyDelete
  13. Hi, this works on 1and1 with php css and html files :)

    Using webpagetest.org I still have some issues:-

    Specify a cache validator - The css file is missing a cache validator

    Leverage browser caching - short freshness lifetime, expiration not specified
    (I think this is the same prob as above)

    Minifying the index.php (can this be easily done?)

    Minifying the CSS file (can this be easily done?)

    Combine images into CSS sprites (can I just reduce their size in a similar way to jpgs?)

    Optimizing gif images (how is this done?)

    Thanks, Phil.

    ReplyDelete
  14. I did not get a chance to reply to you, Philip, when you first posted, then forgot to get back with you.

    In any case, check out http://developer.yahoo.com/performance/rules.html for ideas on cache validation. For minifying your index.php file, see http://mrrena.blogspot.com/2011/02/how-to-minify-html-using-php-and-minify.html Note that the effects may be negligible or even worsen your page speed.

    All my pages recommended using Minify, linked from this article or http://mrrena.blogspot.com/2009/02/how-to-easily-compress-javascript-and.html That will solve minifying your CSS and JavaScript files.

    Compressing images will not achieve the same result as image sprites. Image sprites make only one call to the server--versus however many individual image calls--and are quite easy to implement. You can generate them online easily with http://spriteme.org/ or for more information, see http://websitetips.com/articles/css/sprites/ or http://www.elated.com/articles/css-rollover-buttons/

    Do note, however, that depending on where and how the images are used, they may require either extra blank space or else not be spritable at all (like tiled background images).

    Finally, to easily optimize GIF images, just install Google's PageSpeed as a plugin to Firefox http://code.google.com/speed/page-speed/download.html and it will compress all such images and allows you to download the newly compressed file--pretty cool.

    ReplyDelete
  15. @Eric, thanks for solution. I thought it is impossible to do with 1and1 hosting.

    ReplyDelete
  16. Using this method I was able to finally gzip my site! Combining this php script to automatically copy the php.ini to every folder made things much easier: http://tips-scripts.com/php_ini_copy

    ReplyDelete
  17. hi,
    very usefull, I get the gzip thru addhandler and headers.php as you suggest, but then it does not do anything with the commands of htaccess for css or js like
    - addExpires
    - Header set

    neither thru filesmatch or ExpiresByType

    any other solution instead of setting it headers.php? why does not affect those commands

    thnx 4 the tutorial

    ReplyDelete
  18. I don't have a great deal of time at the moment to research your question. I will simply say that there is a debate about which is better: using .htaccess to control caching or using headers. The point is, both can be used to accomplish the same end.

    That means that if your .htaccess file no longer affects your JS and CSS files, you should be able to add equivalent headers to your headers.php file as mentioned under the "Update" heading above. In most cases you can use both; for example, for all my images (which aren't using the technique described here), I have the following lines in my root .htaccess file:

    ExpiresActive On
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"

    ...which tells Apache to cache my images for a year.

    While I don't have time to research which headers you'll need for your JS and CSS files, I do have time to share with you the links to some of my personal bookmarks of pages I have found very helpful in the process of getting everything up to speed.

    For cache control in general:
    "Cache Control Directives Demystified" -- http://palisade.plynt.com/issues/2008Jul/cache-control-attributes/
    "Caching Tutorial for Web Authors and Webmasters" -- http://www.mnot.net/cache_docs/

    For Apache specifically:
    "Use Server Cache Control to Improve Performance" -- http://www.websiteoptimization.com/speed/tweak/cache/
    "Stupid htaccess Tricks" -- http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
    "more .htaccess tips and tricks.." -- http://corz.org/serv/tricks/htaccess2.php
    "mod_rewrite Quick Reference and Cheat Sheet" -- http://semlabs.co.uk/journal/mod_rewrite-quick-reference-and-cheat-sheet

    Hope that helps. The first two resources in the first list should help you out most in using an equivalent solution for headers.php that you are currently using in your .htaccess file.

    ReplyDelete
  19. P.S. To target individual files, you'll need to include some conditional logic in your headers.php file. For example, something like this might do the trick:

    if ($_SERVER['SCRIPT_NAME'] == '/scripts_dir/my_special_file.js') {
    //add these additional headers
    }

    To see a list of available PHP variables, save a PHP file containing just the following three lines and upload to your server, then just access the page through your browser:



    ...saved as "phpinfo.php"

    ReplyDelete
  20. Sorry... the three lines got chopped off because I didn't use HTML Entities for the "<" and ">" symbols. Here is again:

    <?
    phpinfo();
    ?>

    ReplyDelete
  21. A simple way to get 1and1 to compress php files/pages is to simply create a php.ini file (which as you describe must be placed in every folder) containing the single line:

    zlib.output_compression = On

    Once this is in place php files will be compressed. It does not work for other file types, e.g. .html, .css etc., although if you choose to name your css and other files .php they will then be compressed, although served with the incorrect MIME type of text/html which may cause problems with some user-agents.

    If you elect to use minify to compress and serve css and js files (as described in your article on this), then you also ‘cure’ your css and js file issue. This then only leaves .html/.htm or other static files which of course you could simply name .php to gain compression; you don’t actually need to alter the content of the files in any way.

    One benefit of using the php.ini solution above is that it has the advantage of using the zlib compression which is the php recommended approach in preference to use of ob_gzhandler (ref.: http://php.net/manual/en/function.ob-gzhandler.php).

    Having got this to work I have carried on looking at getting .html/.htm/.shtml and other file types parsed via php as you describe, and on 1and1 in Germany at least, had no luck at all. In looking at your article you add the following to .htaccess:

    AddType x-mapp-php5 .php .shtml .html .htm .txt .js .css

    However, AddType adds a MIME type and so results in any files marked-up like this being served, not as text/html or whatever, but as ‘Content-type: x-mapp-php5’. This then causes the browser to ask what you want to do with this unknown MIME type document and asking whether you want to save the file rather than render it. Not the intended outcome :-)

    I have tried AddHandler as a means to associate a handler with particular file types but this has failed and I have even managed to generate the odd internal server error or two :-)

    ReplyDelete
  22. And while going through all this a few more tricks I’ve been playing…

    Adding/correcting file MIME types with:

    AddType image/x-icon ico
    AddType application/javascript js

    (1and1 otherwise serve .ico files with no/an unknown MIME type and .js files as application/x-javascript…although there’s argument about the relative merits of application/javascript vs. text/javascript)

    Also setting client-side caching with:

    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A0
    ExpiresByType image/gif A1200
    ExpiresByType image/jpeg A1200

    </IfModule>

    This add a max-age of a number of seconds, so A1200 = 20 minutes to whatever types you define. And why 20 mins and not a month? Well, if you have lots of users returning to your site numerous times over the course of a month, or year, fine, although you can then stale cache issues unless you use resource version numbers (e.g. image.jpg?version=20110912), however, if people typically come for 10 or 15 mins, having them cache an object for a year doesn’t really buy anyone very much.

    Custom error pages with:

    ErrorDocument 400 /errorPages/bad_request.html

    Although oddly I’ve found on 1and1 that this works if the incorrect URL isn’t a php URL. So a request for ‘missing.jpg’ gives you the custom 404 page, but a request for ‘missing.php’ still gives you a 1and1 page saying the domain has just been registered!! Not what you want, so I’ve not cured that one yet.

    I’ve also found if you get ‘near misses’ 1and1 substitute a file of similar file extension. So create a simple test page and call it ‘simple.shtml’ (note the ‘s’-html). Now request ‘simple.html’ (note the no-‘s’) and you don’t get a 404, you instead get the .shtml file! If you request ‘simple.htm’ you even get a page suggesting you might like ‘simple.shtml’! You can also get similar .php offered to you instead of either a 404 or your custom 404 page. Interesting stuff going on in the 1and1 httpd.conf!

    And finally I’ve been playing with ‘friendly’ (or short) URLs, with:

    Redirect 301 /short/ http://www.yourdomain.com/somepath/anotherlevel/controller.php?page=101&theme=xyz

    ReplyDelete
  23. Hi Iain,

    Thanks for your comments!

    So far as I'm aware, when you use AddType x-mapp-php5, you're running those file extensions through PHP 5's file handler. I would think that just as step 2 in the article above delves into changing the header information sent for JS and CSS files, you'd probably also need to add HTML and possibly TXT files to the list as well:

    if ($extension == 'htm' || $extension == 'html' || $extension == 'shtml') {
    header('Content-type: text/html; charset=utf-8');
    }

    You might try that, and if it works, definitely post back here for everybody else's benefit.

    And I'll admit, this solution's not glamorous, but it is a way around the default settings on 1&1's shared servers. ;)

    ReplyDelete
  24. I'm afraid AddType isn't a directive for the server to parse a file, it simply defines a MIME type that files with a particular file extension should be served as. I quote:

    [quote]The AddType directive maps the given filename extensions onto the specified content type. MIME-type is the MIME type to use for filenames containing extension. This mapping is added to any already in force, overriding any mappings that already exist for the same extension. This directive can be used to add mappings not listed in the MIME types file (see the TypesConfig directive).

    Example: AddType image/gif .gif

    It is recommended that new MIME types be added using the AddType directive rather than changing the TypesConfig file.

    The extension argument is case-insensitive, and can be specified with or without a leading dot.[/quote]

    See: http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addtype

    So you could for instance define [code]AddType text/html .gif[/code] and have images rendered as a meaningless text stream by your browser. Not something you’d want to do, but illustrates the point. Therefore:

    AddType x-mapp-php5 .php .shtml .html .htm .txt .js .css

    Means that files with the listed extensions are served with a MIME type of x-mapp-php5 which means nothing to the browser, hence it asks you what you want done with the file. If you look at the HTTP response with this directive in place you see:

    HTTP/1.1 200 OK
    Date: Mon, 26 Sep 2011 18:12:54 GMT
    Server: Apache
    Content-Encoding: gzip
    Vary: Accept-Encoding
    X-Powered-By: PHP/5.2.17
    Keep-Alive: timeout=2, max=200
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: x-mapp-php5

    Note that last line…Content-Type. It should read, and indeed does without the AddType x-mapp-php5… directive, as:

    Content-Type: text/html


    In contrast if you look at AddHandler:

    [quote]Files having the name extension will be served by the specified handler-name. This mapping is added to any already in force, overriding any mappings that already exist for the same extension. For example, to activate CGI scripts with the file extension .cgi, you might use:

    AddHandler cgi-script .cgi

    Once that has been put into your httpd.conf file, any file containing the .cgi extension will be treated as a CGI program.

    The extension argument is case-insensitive, and can be specified with or without a leading dot.[/quote]

    See: http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addhandler

    The documentation then shows the following example:

    [quote]Server Side Includes example

    Another common use of .htaccess files is to enable Server Side Includes for a particular directory. This may be done with the following configuration directives, placed in a .htaccess file in the desired directory:

    Options +Includes
    AddType text/html shtml
    AddHandler server-parsed shtml

    Note that AllowOverride Options and AllowOverride FileInfo must both be in effect for these directives to have any effect.[/quote]

    So maybe ‘AddHandler server-parsed shtml’ (or css, js etc.) is a route to try? I’ll experiment…

    ReplyDelete
  25. Another observation with 1and1...

    If you set a error document directive as in:

    ErrorDocument 404 /errorPages/not_found.html

    this is only effective for non php URLs. So /missing.gif or /missing.html will give you your custom error page, but /missing.php will still lead you to the horrible 1and1 "This domain name has just been registered." error page!

    ReplyDelete
  26. Cool. Thanks for the heads up. :)

    ReplyDelete
  27. Is there a way to use your method to compress my website while also allowing my htaccess file to continue hiding the .html file extensions of each webpage?

    This big of code seems thrown out of sorts when I paste in your code. (Probably because of the rerouting it through php part?)

    #
    Options +FollowSymLinks
    RewriteEngine On
    #
    # REDIRECT /folder/index.html to /folder/
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.html$ http://weaverinnovations.com/$1 [R=301,L]
    #

    ReplyDelete
  28. Apache and PHP should play okay together.

    Try this (from a comment @ http://php.net/manual/en/security.hiding.php -- I just changed the file extension from "php" to "html" per your example above):

    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.+)$ /$1.html [L,QSA]

    It might not get rid of your "index.html" page in "folder," but if you add the following at the top of your .htaccess file, it will at least ensure that "http://weaverinnovations.com/folder/" will be able to access "index.html" without showing it. (It will not, however, keep it from showing if the full path is accessed.)

    DirectoryIndex index.html

    If this works out for you, you might comment back to leave a record for the next weary web traveler. :)

    Peace out,
    Eric (aka mrrena)

    ReplyDelete
  29. I should add that if you're on 1&1 (and maybe even if you're not),

    DirectoryIndex index.html

    would go inside the .htaccess file inside the "folder" directory, not the root directory (unless it too has a "index.html" file, and then you'll need it both places).

    ReplyDelete
  30. Anonymous5:18 PM

    hi i am trying this on 1and1 and the second i put the .js and .css in the htaccess file the site poops out. doesnt use js or css. i have done everything else perfectly as outlined above. even tried the [ header("Vary: Accept-Encoding");
    if ($extension == 'css') { ]

    also tried the remove handler note as well. not sure if i did something wrong, but i followed this step by step

    ReplyDelete
  31. Awesome dude, Ive been searching the net for weeks looking for an answer to this conundrum, 1and1 certainly cant help! Brilliantly explained for the novice too. Thanks and keep up the good work.

    ReplyDelete
  32. Hello
    Many thanks for this post
    For me it didn't totally work. I've followed your guide step by step, and gain some speed, but GIDZip confirm I do not have Gzip active on my site www.fengshuienfrance.fr
    Very frustrating as I'm using a great plugin to speed up my site, but it's limited if I can't use Gzip. Of course I am with 1&1...Any helps appreciated!

    ReplyDelete
  33. Have you got any tips on how to make this file ignore a folder e.g. /blog as its working perfectly on my site but my blog which is wordpress has now stopped working properly e.g. its not reading the .css in the admin section.

    ReplyDelete
  34. An invaluable guide! -Much Thanks!

    ReplyDelete
  35. If you create a file called .user.ini rather than php.ini it automatically applies to all folders below its folder, rather than just to the folder it's in. Sweet!

    ReplyDelete
  36. Awesome worked flawless. htacccess alone would not suffice. Thanks again. http://africasiaeuro.com

    ReplyDelete
  37. Thank you so much for the Tutorial.

    I had trouble with a minified .css File (admin-bar.min.css) that started with an ID (#id). I guess the problem was that php ignored the line that started with a # as a comment. I changed part of the code from Part 2:

    if ($extension == 'css') {
    header('Content-type: text/css');
    }

    became

    if ($extension == 'css') {
    header('Content-type: text/css');
    echo file_get_contents($_SERVER["SCRIPT_FILENAME"]);
    exit;
    }
    which echos the content of the .css file and then exits the script to not echo the content again. Solved the Problem for me.

    @Giordy: Thank you for the tip with .user.ini. Works like a charm.

    ReplyDelete
  38. Thanks for sharing the codes, You can also avail Linux shared hosting services by Go4hosting. You will never face any problem in it.

    ReplyDelete
  39. For Cloud Hosting Services please visit CloudOYE and 24*7 Support System....

    ReplyDelete
  40. This comment has been removed by the author.

    ReplyDelete
  41. I should add as june/2015 that the line actually is: AddHandler x-mapp-php5.5 .php .html .htm .js for PHP 5.5 and you can use Autoptimze plugin to WP forcing all css style to inline and no more nothing in WP and 1and1 to get the best . Worked for me with membershirp and course together and no other cache...

    ReplyDelete
  42. Fahimshakir Freelancer Developer from Delhi-India,You can provide me part time work for Home,Part Time Developer/Freelancer For PHP , WordPress, Magento, Opencart, Shopify, Codeigniter, Website Maintenance in Delhi -india, www.fahimshakir.com

    ReplyDelete
  43. We are UK based company who specialise in performance base layers and compression wear. We take pride in offering great high quality compression products at amazing prices. We believe customer service is integral to our success and we constantly strive to provide the best service possible to all of our customers. Here are options for compression top, compression tights, compression leggings, compression shorts and Baselayer.

    ReplyDelete
  44. waooo nice post about "How to Compress PHP and Other Text-Based Files with 1&1 (and Other Shared Hosts)"

    Thanks,

    Crude Oil Trading Tips | Mcx Tips Free Trial

    ReplyDelete
  45. Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!


    Melbourne Web Developer

    ReplyDelete
  46. Hi, as 23jul17 I had so many different issues, 1and1 america, with the site optimization and the .htaccess and php.ini - even WP or some other CMS website project so I start to use: https://github.com/fhoech/gz.php - well positive is offer htaccess support and work out of the box straight, just select the options you want, the special advantage: create a full static website zipped - also html, css and js and even though it is stated that it does not remake the new updated files but it is not true, it works perfectly without any extra server overload... give a try and forget problems about which version of PHP you use or something else alike.... By the way to our beloved readers: 1and1 in Europe - specially France, offers support to gzipping out of the box straight from the .htaccess finishing the problem of the American 1and1 website/host!!!! and the prices in Europe are quite good the same.......
    Welcome to test and enjoy the script at the link above, I guess will save time and effort to a lot of people....

    ReplyDelete
    Replies
    1. Ok to be more specifical: can work over the fly, can create static version of files, also auto update the files in static version. Create minimized and compressed version the only con is the script doesn't combine script or css in one file like a regular plugin, have different gits that offer this feature but I didn't see any of them work with !and1 America host yet... well sirvuple: https://github.com/fhoech/gz.php

      Delete
  47. This comment has been removed by the author.

    ReplyDelete
  48. This comment has been removed by the author.

    ReplyDelete
  49. Hey! I have read all your Blog this So Nice and Awesome service you have provided, I learn many new things from here and want implement my website. If you are also Know for something New related to Shopify Uk this then visit my website.

    ReplyDelete
  50. If a service is tough to sign up for, the majority of people will move on to the next hosting service. Click here to know more about VPS Malaysia | Proven and Tested Hosting Services | Why Us.

    ReplyDelete
  51. quite secure message. I simply stumbled concerning your blog and desired to proclaim that i've in reality loved studying your blog posts. Any pretentiousness i'll be subscribing on your feed and i slope you publicize anew quickly. huge thanks for the useful data. https://www.vaporwavetext.online/

    ReplyDelete
  52. Thanks a lot for sharing it, i got here huge knowledge i like you website and bookmarked.
    Visit games.lol for Arcade Games

    ReplyDelete
  53. Amazing article …… Thanks for sharing this …. and keep it up!!
    Visit games.lol for Puzzle Games

    ReplyDelete


  54. نجار بالمدينة المنورة
    لا يوجد مكان لا يحتاج إلى نجار بالمدين المنورة فهو واحد من الكوادر التي تعتمد علية الشركة في تنفيذ الكثير من الأعمال التي تحتاج إلى معلم نجار بالمدينة المنورة، فهو من يساعكم في تركيب غرف نوم بالمدينة المنورة، وتركيب مطابخ بالمدينة المنورة، وتركيب أثاث بالمدينة المنورة، كما أنه من العمال المعتمد عليهم أثناء عمليات نقل الأثاث لأنه من العمال الذي يمكن أن تضع ثقتكَ به في عملية فك وتركيب الأثتث المنزلية أو الأثاث المكتبي.
    كما أنه يمتلك المعدات والأدوات التي تساعد في فك وتركيب الأثاث وتركيب النوافذ والأبواب الخشبية، حيث يكون بإمكان نجار بالمدينة المنورة القيام بكافة الأعمال الذي يحتاج إليها جميع عملاء المدينة المنورة في أقل وقت وبأعلى مستوى.



    ReplyDelete
  55. Thanks for a nice share you have given to us with such an large collection of information.
    Great work you have done by sharing them to all. for more info
    simply superb.smart class in bhopal
    autocad in bhopal
    3ds max classes in bhopal
    CPCT Coaching in Bhopal
    java coaching in bhopal
    Autocad classes in bhopal
    Catia coaching in bhopal

    ReplyDelete
  56. Very nice blog
    For best AWS training in bangalore,
    Visit: AWS training in bangalore

    ReplyDelete
  57. Anonymous12:54 AM

    For Hadoop Training in Bangalore Visit:
    Hadoop training in bangalore

    ReplyDelete
  58. Anonymous5:11 AM

    For Devops Training in Bangalore Visit:Best Devops Training in Bangalore

    ReplyDelete
  59. Anonymous4:10 AM

    For IOT Training in Bangalore Visit : IOT Training in Bangalore

    ReplyDelete
  60. Linking is very useful thing.you have really helped lots of people who visit blog and provide them use full information.Automation Anywhere Training in Bangalore

    ReplyDelete
  61. Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.blue prism training in bangalore

    ReplyDelete
  62. This is really an awesome post, thanks for it. Keep adding more information to this.openspan training in bangalore

    ReplyDelete
  63. This post is really nice and informative. The explanation given is really comprehensive and informative . Thanks for sharing such a great information..Its really nice and informative . Hope more artcles from you. I want to share about the best java tutorial videos for beginners with free bundle videos provided and java training .

    ReplyDelete
  64. http://healthsgroup.com/ http://healthsgroup.com/

    ReplyDelete
  65. Thanks for the informative article About Selenium. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete
  66. I am overwhelmed by your post with such a nice topic. Usually I visit your blogs and get updated through the information you include but today’s blog would be the most appreciable. Well done!

    Business Analytics Training | Business Analytics Course In Hyderabad

    ReplyDelete
  67. As a matter of fact, some people don't even know what they want to do when it comes to renting a server. They are new to the game and want to get a hold of the information that they need. To get more detailed info on servers to rent, visit on hyperlinked site.

    ReplyDelete
  68. The article was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents.
    by cognex offers AWS Training in Chennai. Cognex offers AWS training in Bangalore using classroom and AWS Online Training globally.

    ReplyDelete
  69. Yes, Without SEO, no one can survive online.
    So why our team of SEO agencies in Bangalore focus completely on Off-page and On-page SEO optimization.If anyone wants to hire us, please feel free to reach us @ weblogicks.com.

    ReplyDelete
  70. Anonymous5:57 AM

    Get unlimited bank web hosting solutions and support. I have got the full satisfaction of my web hosting server in this blog post.
    Germany VPS Server

    ReplyDelete
  71. Anonymous2:40 PM

    Hi!! Very interesting information glad that I came across such an informative post. I really liked your Information. Keep up the good work friend.
    France VPS Server

    ReplyDelete
  72. As you are providing information about How to Compress PHP and Other Text-Based Files with 1&1 (and Other Shared Hosts) that is extremely good for everyone. Basically, we want to say that your knowledge really impressive that should be spread all over the world. Basically, We are leading server hosting Company. There are lots of companies available in the market that provides the hosting solution. if you want any other information about server hosting Contact us without any hesitation. Onlive Server and Onlive Infotech here are available multiple types of server hosting solutions. for more information Click here - USA VPS Hosting.

    ReplyDelete
  73. SME's can be a great way to add a little bit of extra marketing to an existing website because they don't have the overhead expenses associated with larger companies.

    ReplyDelete

  74. I see the greatest contents on your blog and I extremely love reading them. ExcelR Data Science Course In Pune

    ReplyDelete
  75. Digibrom is the Best Digital Marketing
    Training & Services In Bhopal
    Digibrom is the Best Digital Marketing Training & Services in Bhopal, providing complete digital growth for your business. We are one of the leading Digital Marketing company in Bhopal, and we are experts in digital marketing & web design. The market penetration along with the use of digital technology is our power. We serve businesses according to the need and requirements of the customers and deliver quality work in time because Digibrom is the best digital marketing training institute in Bhopal and service provider. We create likable content that increases the time spent by the customer on the internet.Digital Marketing is one of the greatest opportunities for a great career. Including lots of opportunities within the field and attractive salaries, it’s the best time to connect a digital marketing Training. These days Digibrom is the Best Digital Marketing Training In Bhopal. it has become a demand for professions to have a solid online presence and for that, people need to get help from digital marketing companies to improve their online appearance. Digibrom is the best digital marketing Training & Services company in Bhopal.
    Digital marketing training in bhopal

    Best digital marketing company in bhopal

    ReplyDelete
  76. Thank you for sharing this valuable content.
    I love your content it's very unique.
    DigiDaddy World

    ReplyDelete
  77. Kim Ravida is a lifestyle and business coach who helps women in business take powerful money actions and make solid, productiveIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder

    ReplyDelete
  78. this article is interesting to read and useful.thanks for sharing
    Angular training in Chennai

    ReplyDelete
  79. I found so many exciting matters in this particular content, I would like to request please keep posting such informative content. Check out thinking of you messages for her 

    ReplyDelete
  80. Anonymous2:58 AM

    Wow! Nice post
    I read your post that is great. I am very impressed with your suggestion. You go forFrance Dedicated Server Hosting Thanks for sharing it with us

    ReplyDelete
  81. Anonymous5:20 AM

    Your post is too good. This is very unique information for me. fantastic blog post. Thanks for sharing this type of informative blog post. Dubai Dedicated Server Hosting

    ReplyDelete
  82. Anonymous5:23 AM

    It was wonderfull reading your article. Great writing style. You can buy the best Sweden Dedicated Server Hosting services for your website at a reasonable price from Onlive Server.

    ReplyDelete
  83. Anonymous5:25 AM

    Really glad to inform that it's an awesome post to read and learn something new, I always come to know about something interesting and unique.
    keep Go like this!!!!!!!!!!1
    Spain Dedicated Server

    ReplyDelete
  84. Anonymous5:33 AM

    Thanks for sharing your plan and view, this is goodly.
    India Dedicated Server Hosting

    ReplyDelete
  85. Anonymous5:45 AM

    Wow!! Thank you for sharing helpful information. I really like your article. If you want to know about the best Ukraine Dedicated Server you visit this. you can ask us for more details.

    ReplyDelete
  86. I never read an informative blog such as this. I really appreciate your work. keep it up and keep updating.

    ReplyDelete
  87. Redmi is tipped to launch the Redmi K50 series in February 2022. Which means this phone launch next in starting in February .click here for this news Redmi K40 Gaming Gets Approved In China
    For All News Click Here Nindia24

    ReplyDelete

  88. شركة تنظيف المنازل بالرياض

    بالرياض شركة تنظيف تعد من كبرى شركات التنظيف بالرياض المتواجدة في المملكة العربية السعودية وذلك ما تسعى دوماً تهتم بتقديم خدمة تنظيف المنازل بالرياض والتي تعتبر من أصعب المهام التي من الممكن أن تقوم بها ربة المنزل بمفردها، وذلك يرجع للعديد من الأسباب أهمها عدم توفير الوقت والمجهود الكافي للقيام بذلك الأمر، إلى جانب كثرة الأعباء الحياتية.

    ReplyDelete
  89. Whether you sell products or services, you need to have a good logo. A logo is the face of your company. It should be visually engaging and easy to use. To learn more about web marketing, discover here.

    ReplyDelete
  90. Best game development company in Noida-Kickr Technology's range of services covers concept enhancement, concept art, character design, animation,game mechanics, programming, and testing. As a leading game design and development company, this makes us your one-stop shop for all your needs.

    ReplyDelete
  91. You'll be glad you did. So, start planning today and enjoy your newfound success. Sixrs is a company that provides advertising services to both large and small businesses.To get more detailed info on web design, visit on hyperlinked site.

    ReplyDelete
  92. People are impressed with this technology, and the experts have predicted a bright future of data science.

    data science course in lucknow

    ReplyDelete
  93. this is a pounding blog. I wind it. you have such a lot of mastery about this depend, and as a repercussion a ton enthusiasm. You further to know a method for making individuals rally toward the back it, clearly from the reactions. https://cyberspc.com/microsoft-office-2016-product-key/

    ReplyDelete
  94. Glorious web site! I love the way it is straightforward upon my eyes it's far. I'm contemplating the way in which I might be prompted whenever another conspicuous screen has been made. glancing through out extra new updates. Have a colossal extensive stretches of significant stretches of light hours!! Son In Law Birthday Wishes

    ReplyDelete
  95. I really enjoyed reading your post! It was not only informative but also helped me enhance my knowledge with the latest information. Please continue blogging. Your article is well-written and contains valuable information that is beneficial for readers. Thank you for sharing it, and I look forward to reading more posts like this from you.

    Best MEC Colleges in Hyderabad

    ReplyDelete
  96. I strongly believe in leaving comments on websites to inform blog writers that they have contributed something valuable to the internet, Thanks for sharing.

    Colleges for BBA In Hyderabad

    ReplyDelete