Welcome Guest, Not a member yet? Register   Sign In
Assets compression with Controller is good or not?
#1

[eluser]umefarooq[/eluser]
is this good way to compress your css and js with controller just pass css and js file to controller and it will output gzip asset

Code:
http://localhost/compressed/assets/cache/cssfile.css
  
  http://localhost/compressed/assets/cache/cssfile.js
  
  here segment 2 and 3 are directories segment 4 is your asset

just want to know is it xss save or not if somebody will interested will share controller code

im using code from this example

http://css-tricks.com/snippets/css/compr...-with-php/
#2

[eluser]frist44[/eluser]
Are you getting that much traffic that this actually matters. If so, I would just look to minify the file to start so that it doesn't have to do it on the fly. If the assets are still that much of a pain and overloading a server, look to put them out on a CDN somewhere so your server is not responsible for it.
#3

[eluser]cahva[/eluser]
If you're using apache, look for mod_deflate which you can use to compress the output for certain files (css, js.. text) without parsing your css or js files using PHP.

Check out Carabiner. It has minify (and IMO even more important combine) options built-in. It writes the css and js files to cache directory and apache can serve them directly without using PHP. It is clever enough if you change css or js and it will create new cachefiles for those.
#4

[eluser]umefarooq[/eluser]
well i have used carabiner in my projects successfully only thing is asset compression in not available in carabiner i have check that css with out gzip is about 37kb when i gzip css file and its about 7kb, and every byte mater
#5

[eluser]cahva[/eluser]
Thats why I mentioned mod_deflate. It will compress all js, css and html for you.
#6

[eluser]cahva[/eluser]
Heres an example that I have added to one virtual host:

Quote:AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/java application/x-javascript

<Location / >
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>




Theme © iAndrew 2016 - Forum software by © MyBB