2

I would like to configure Wro4j in such a way that it should dynamically enable/disable cache based on the properties file (not wro.properties)

is implementing a custom RequestHandeler good ideal? Please let me know if there is any possible way to do it.

Moreover, It would be really great if i can do that based on request parameter:

eg: calling the URL /wro/main.css?disableCache=true should give me the main.css generated by Wro4j (with compete wro4j life cycle) and not from the cache.

Note: I am using spring MVC.

sun2
  • 1,118
  • 1
  • 13
  • 17

1 Answers1

3

The answer was also posted on the wro4j mailing list:

You could achieve this with a custom RequestHandler. The handler would accept request having disableCache request param set to true and the implementation would invalidate the cache for the requested group: cacheStrategy.put(cacheKey, null);

But before using the above approach, I would suggest a simpler one:

resourceWatcherUpdatePeriod=5
resourceWatcherAsync=true

The above two configuration properties should ensure that you get the most recent result after 5 seconds. The wro4j would check for you if there are any changed resources and will process them asynchronously without affecting your development cycle.

UPDATE

An example implementing the custom request handler which invalidates the requested group when the disableCache parameter is provided is available here.

Alex Objelean
  • 3,893
  • 2
  • 27
  • 36
  • Replied on wro4j mailing list too. I am looking for something like calling /wro/main.css?disableCache=false should give me result from cache and /wro/main.css?disableCache=true should give me result by freshly generated wro4j life cycle. Moreover I already have resourceWatcherUpdatePeriod configured. It would be really great if you can give me more inside of requestHander.Any example would be really helpful. – sun2 Feb 11 '14 at 15:57
  • The wro.properties way worked for me. This answer deserves more upvotes – Andrea Ligios Nov 16 '16 at 08:28
  • Ah, you are the wro4j dev :) Good job then – Andrea Ligios Nov 16 '16 at 08:30