New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS compression Improvement suggestion #117

Closed
danyj opened this Issue Nov 12, 2017 · 1 comment

Comments

2 participants
@danyj

danyj commented Nov 12, 2017

Hi there bud. Finishing theme and found your post on how to decrease the cache size since I noticed that with autoptimize every page creates its own unique compiled CSS file.

http://prntscr.com/h9jvp2

Not sure how you are making file names but for my theme I figured out an awesome improvement since I did same thing you did.

I have 7 default theme files which are combined in to one, on compile, http://prntscr.com/h9jw1u
than dynamic ( inline CSS )
Instead of creating css file for each unique page I now create name with ( looks like you are doing same )

wp_hash($inline_css);

and save it in DB under the cached files option per page

	$option[ $pageid ] = array(
	
		'time' => time(),
		'fonts' => $google_font_url,
		'cached' => wp_hash($inline_css);
	
	);

Now on page load this is what goes on

1.a. get the pageid option , check the cache file name , if file is there serve it

1b. Read the inline CSS
2. save time , fonts , cached name to DB
3. compress new one since we have unique page

this way on pages that have same inline CSS I dont have to compress again

On my demo I have WC, portfolio , events , blog , bbpress etc , so if I dont monkey around and make custom option per each page and category I can get away with 3 4 files that are reused. http://prntscr.com/h9k3bf

@futtta

This comment has been minimized.

Show comment
Hide comment
@futtta

futtta Nov 13, 2017

Owner

Interesting idea indeed @danyj, as it allows one to optimize inline CSS without busting the cache! For now I advice people to disable the "also aggregate inline CSS"-option if theres monkeying around going on ;-)

Owner

futtta commented Nov 13, 2017

Interesting idea indeed @danyj, as it allows one to optimize inline CSS without busting the cache! For now I advice people to disable the "also aggregate inline CSS"-option if theres monkeying around going on ;-)

@danyj danyj closed this Nov 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment